内容目录
						
						private static void RunPowershellScript(string scriptFile)
{
    ProcessStartInfo ps = new ProcessStartInfo(@"powershell.exe",scriptFile) { RedirectStandardOutput = true };
    //ps.CreateNoWindow = true;
    var proc = Process.Start(ps);
    proc.OutputDataReceived += (s, e) =>
    {
        Console.WriteLine(e.Data);
    };
}会弹出 Powershell 窗口,但是需要注意,PowerShell 不会输出完整内容。
如果需要 Powershell 输出执行的命令的所有日志,需要设置 RedirectStandardOutput = false
 
		
文章评论