The following ping is used as an example to use the namespace System.Diagnostics;
The System.Diagnostics namespace contains classes that can interact with system process event logs and performance counters to help diagnose and debug applications such as the Debug class used to help group debug code process classes to control processes access Trace class is able to track code execution
Processes are used to manipulate local or remote process access through the process can be easy to operate in a managed environment to start or stop an external process.
Copy Code code as follows:
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Diagnostics;
Namespace Testequal
{
Class Program
{
static void Main (string[] args)
{
Process myprocess = new process ();
MyProcess.StartInfo.FileName = "Iexplore.exe";
myProcess.StartInfo.Arguments = "http://www.baidu.com";
Myprocess.start ();
}
}
}
appropriate filename and arguments properties must be set
Let's take ping as an example
The code is as follows:
Copy Code code as follows:
string hostname = "http://www.baidu.com"; Or here is the IP and so on;
Process prc=new process ();
Prc. Startinfo.filename= "cmd.exe";
Prc. Startinfo.useshellexecute=false;
Prc. Startinfo.redirectstandardinput = true;
Prc. Startinfo.redirectstandardoutput = true;
Prc. Startinfo.redirectstandarderror = true;
Prc. Startinfo.createnowindow = false;
Prc. Start ();
Prc. Standardinput.writeline ("ping" + hostname);
Prc. Standardinput.close ();
Response.Write (PRC. Standardoutput.readtoend ());
Here you can also invoke many commands that you can study under