I am opening the command prompt from c#
Process.Start("cmd");
when it opens i need to write ipconfig automatically such that process opens and finds the ip of the workstation, How should i do that?
EDIT
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "ipconfig.exe";
p.Start();
p.WaitForExit();
string output = p.StandardOutput.ReadToEnd();
return output;
or
EDIT
Process pr = new Process();
pr.StartInfo.FileName = "cmd.exe";
pr.StartInfo.Arguments = "/k ipconfig";
pr.Start();
Check : How to Execute a Command in C# ?
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "ipconfig";
process.StartInfo = startInfo;
process.Start();
or
Try this
string strCmdText;
strCmdText= "ipconfig";
System.Diagnostics.Process.Start("CMD.exe",strCmdText);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With