我编写代码,调用powershell脚本来执行。问题是在Windows 7上,所有工作都很完美。但在Windows 8.1中,五个中的一个开始冻结。所以这是我的代码:
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = @"powershell.exe";
startInfo.Arguments = PathUnistallScript;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
Process process = new Process();
process.StartInfo = startInfo;
process.Start();
string output = process.StandardOutput.ReadToEnd();//here code is freezes
目前我放了一个拐杖,但我认为这是一个临时解决方案。
Process process = new Process();
process.StartInfo = startInfo;
process.Start();
Thread.Sleep(5000);//wait the approximate number of seconds to complete the script
process.Kill();
如何编写代码,它不会在Windows 8.1中冻结?