Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 正在尝试使用ProcessStartInfo和Process从方法中运行slui.exe_C#_Win32exception - Fatal编程技术网

C# 正在尝试使用ProcessStartInfo和Process从方法中运行slui.exe

C# 正在尝试使用ProcessStartInfo和Process从方法中运行slui.exe,c#,win32exception,C#,Win32exception,我在从c#中的方法运行slui.exe时遇到问题。我正在使用代码: ProcessStartInfo startInfo=newprocessstartinfo(@“C:\Windows\System32\slui.exe”); 过程p=新过程(); p、 StartInfo=StartInfo; p、 Start(); p、 WaitForExit(); 但我一直收到一个Win32Exception:“系统找不到指定的文件” 如果我将ProcessStartInfo更改为:(@“C:\Win

我在从c#中的方法运行slui.exe时遇到问题。我正在使用代码:

ProcessStartInfo startInfo=newprocessstartinfo(@“C:\Windows\System32\slui.exe”);
过程p=新过程();
p、 StartInfo=StartInfo;
p、 Start();
p、 WaitForExit();

但我一直收到一个Win32Exception:“系统找不到指定的文件”

如果我将ProcessStartInfo更改为:(@“C:\Windows\System32\cmd.exe”),它将正常启动

在这个上下文中运行slui.exe是否有问题

我确信该文件位于指定的目录中,因此我很难理解这里可能出了什么问题


关于如何从c#方法调用slui.exe,您有什么想法吗?

slui.exe仅在Windows x64上作为64位程序提供。当您作为32位进程运行时,硬编码路径c:\windows\system32将被重新定向到c:\windows\syswow64。因此无法找到该文件


项目+属性,编译选项卡,将平台目标设置更改为“AnyCPU”。对发布配置重复上述步骤。并使用Environment.GetFolderPath()确保它在Windows未安装到c:\Windows时仍能工作。

您是否确实转到了目录本身并确保文件在那里?您可以尝试
file.Exists(@“c:\Windows\System32\slui.exe”)
以查看系统是否确实知道该文件在那里。嗯,不要硬编码路径!您如何知道他们的Windows文件夹位于'C:\Windows`?当它是64位安装时会发生什么?还是32位安装?为什么还要运行该文件?那个exe不是和Windows激活有关吗?你是在表演一种不那么美味的表演吗?事实发生三年后,我才花了三分钱,但我目前也在尝试运行slui.exe,我远没有尝试表演一种“不美味”的表演。我正在尝试运行Windows激活对话框,以防在软件安装程序中检测到Windows未激活。尝试运行slui.exe并不一定是可疑的。因此,它可以在安装了VS2010并以调试模式运行的计算机上运行。。。但是,当我在另一台机器上编译并运行它时,它会立即退出,而不会打开激活窗口。我有一个.manifest,并已将执行级别设置为:“highestAvailable”。。。所以我认为这不是权限问题,我更改了环境变量的硬编码路径。有什么想法吗???再次感谢所有的帮助!!!