System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
                //ComSpecのパスを取得する         
                psi.FileName = System.Environment.GetEnvironmentVariable("ComSpec");
                //出力を読み取れるようにする
                psi.RedirectStandardInput = false;
                psi.RedirectStandardOutput = true;
                psi.UseShellExecute = false;
                //ウィンドウを表示しないようにする
                psi.CreateNoWindow = true;
                //コマンドラインを指定("/c"は実行後閉じるために必要)
                psi.Arguments = @" /c powershell.exe -PSConsoleFile ""C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1"" -command "".'" + psFile + @"'"" 2> """ + logFile + "\"";
                //起動
                System.Diagnostics.Process p = System.Diagnostics.Process.Start(psi);
p.WaitForExit()
                p.Close();
あるいは
System.Diagnostics.Process process = new System.Diagnostics.Process();
                process.StartInfo.FileName = System.Environment.GetEnvironmentVariable("ComSpec");
                process.StartInfo.RedirectStandardInput = false;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.CreateNoWindow = true;
                process.StartInfo.Arguments = @" /c powershell.exe -PSConsoleFile ""C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1"" -command "".'" + psFile + @"'"" 2> """ + logFile + "\"";
                process.Start();
                process.BeginOutputReadLine();
                process.WaitForExit();
| 新品価格 | 
この記事がお役にたちましたらシェアをお願いします:)
0 件のコメント:
コメントを投稿