Promoter process. Do not wait until the child process ends. Private Void Simplerun_click ( Object Sender, system. eventargs E)
{System. Diagnostics. process. Start (@"C: \ listfiles. bat");
}
2. Start the sub-process and wait for the sub-process to end and obtain the output.1 Private Void Runsyncandgetresults_click ( Object Sender, system. eventargs E)
2 {
3 System. Diagnostics. processstartinfo PSI = New System. Diagnostics. processstartinfo ( @" C: \ listfiles. bat " );
4 PSI. redirectstandardoutput = True ;
5 PSI. windowstyle = System. Diagnostics. processwindowstyle. hidden;
6 PSI. useshellexecute = False ;
7 System. Diagnostics. Process listfiles;
8 Listfiles = System. Diagnostics. process. Start (PSI );
9 System. Io. streamreader myoutput = Listfiles. standardoutput;
10 Listfiles. waitforexit ( 2000 );
11
12 If (Listfiles. hasexited)
13 {
14StringOutput=Myoutput. readtoend ();
15This. Processresults. Text=Output;
16}
17 }
18
3. Use the default browser to open the URL
1 Private Void Launchill_click ( Object Sender, system. eventargs E)
2 {
3StringTargetUrl=@ Http://Www.cnblogs.com;
4System. Diagnostics. process. Start (TargetUrl );
5}
6