2011-02-23 105 views
0

我正在尝试调用使用Process.Start的可执行文件,并且它仅在Windows XP计算机上抛出Win32异常。这是一台安装在机器上的控制台应用程序。Process.Start抛出Win32异常访问在Windows XP机器上被拒绝

下面的代码示例:

var path = @"C:\mycoolpath\file.exe"; 
var content = "My cool content"; 

using (var process = Process.Start(new ProcessStartInfo(path, content))) 
     process.WaitForExit(); 

这里的堆栈跟踪: System.ComponentModel.Win32Exception(0x80004005的):访问在System.Diagnostics.Process.StartWithShellExecuteEx(的ProcessStartInfo的StartInfo) 被拒绝 在System.Diagnostics.Process.Start() at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)

任何人有任何建议让它在Windows XP机器上工作?

+3

完全疯狂的猜测,但也许你应该授予它访问,所以它不会被拒绝访问? – Mehrdad 2011-02-23 21:59:54

+1

这是一个ASP.NET应用程序或Win32服务? – 2011-02-23 22:01:43

+1

不要让我们猜测异常消息的确切文本。 – 2011-02-23 22:03:34

回答

7

对于ProcessStartInfo,使用UseShellExecute = false可以实现此功能。

相关问题