啟動子進程
不等待子進程結束
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);
}
From:http://tw.wingwit.com/Article/program/net/201311/13745.html