Process.Start 抛出 Win32 异常访问在 Windows XP 机器上被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5097707/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Process.Start throws Win32 Exception Access is Denied on Windows XP Machines
提问by strickland
I'm attempting to call an executable using Process.Start and it is throwing a Win32 Exception only on Windows XP machines. This is a console application installed on the machine.
我正在尝试使用 Process.Start 调用一个可执行文件,它仅在 Windows XP 机器上抛出 Win32 异常。这是安装在机器上的控制台应用程序。
Here's an example of the code:
下面是代码示例:
var path = @"C:\mycoolpath\file.exe";
var content = "My cool content";
using (var process = Process.Start(new ProcessStartInfo(path, content)))
process.WaitForExit();
Here's the stack trace: System.ComponentModel.Win32Exception (0x80004005): Access is denied at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
这是堆栈跟踪: System.ComponentModel.Win32Exception (0x80004005): Access is denied at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) )
Anyone have any advice on getting this to work on Windows XP machines?
任何人对让它在 Windows XP 机器上工作有什么建议吗?
回答by strickland
Using UseShellExecute = false for the ProcessStartInfo lets this work.
对 ProcessStartInfo 使用 UseShellExecute = false 可以让这个工作。