启动子进程
不等待子进程结束
private void simpleRun_Click(object sender SystemEventArgs e)
{ SystemDiagnosticsProcessStart(@C:listfilesbat);
}
启动子进程等待子进程结束并获得输出
private void runSyncAndGetResults_Click(object sender SystemEventArgs e)
{
SystemDiagnosticsProcessStartInfo psi = new SystemDiagnosticsProcessStartInfo(@C:listfilesbat);
psiRedirectStandardOutput = true;
psiWindowStyle = SystemDiagnosticsProcessWindowStyleHidden;
psiUseShellExecute = false;
SystemDiagnosticsProcess listFiles;
listFiles = SystemDiagnosticsProcessStart(psi);
SystemIOStreamReader myOutput = listFilesStandardOutput;
listFilesWaitForExit();
if (listFilesHasExited)
{
string output = myOutputReadToEnd();
thisprocessResultsText = output;
}
}
使用默认的浏览器打开URL
private void launchURL_Click(object sender SystemEventArgs e)
{
string targetURL = @;
SystemDiagnosticsProcessStart(targetURL);
}