I want know if there any way to write command to cli by using c#.
That because I want to write simple GUI program wich writes command like "ping" "telnet" to the CLI of windows.
thanks alot
I want know if there any way to write command to cli by using c#.
That because I want to write simple GUI program wich writes command like "ping" "telnet" to the CLI of windows.
thanks alot
You can use methods of System.Diagnostics.Process & ProcessStartInfo class.
System.Diagnostics.ProcessStartInfo ps = new System.Diagnostics.ProcessStartInfo(put_here_commandOrfilename);
ps.Arguments = put_here_arguments;
ps.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
ps.UseShellExecute = false;
ps.RedirectStandardInput = true;
ps.RedirectStandardOutput = true;
ps.RedirectStandardError = true;
System.Diagnostics.Process process=System.Diagnostics.Process.Start(ps);
process.WaitForExit();
string output = process.StandardOutput.ReadToEnd();
process.Close();
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.