啟動子進程不等待子進程結束
private void simpleRun_Click(object sender
System
EventArgs e)
{ System
Diagnostics
Process
Start(@
C:listfiles
bat
);
}
啟動子進程等待子進程結束並獲得輸出
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 = @http://wwwduncanmackenzienet;
SystemDiagnosticsProcessStart(targetURL);
}
From:http://tw.wingwit.com/Article/program/ASP/201311/21896.html