小编Rex*_*Hsu的帖子

使用Process.Start()启动system32\winsat.exe时出现"找不到文件"错误

我正在尝试使用以下代码运行Windows系统评估工具(winsat.exe):

System.Diagnostics.Process WinSPro =
    new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo WinSSInfo = 
    new System.Diagnostics.ProcessStartInfo();
WinSSInfo.FileName = "cmd.exe";
WinSSInfo.Arguments = "/k winsat.exe";
WinSPro.StartInfo = WinSSInfo;
WinSPro.Start();
Run Code Online (Sandbox Code Playgroud)

如果我只调用cmd.exe,这个代码有效,即使我调用regedit.exe它仍然有效.但是,当我尝试将winsat.exe作为cmd.exe的参数调用时,它会失败.命令提示符显示:

'winsat.exe' is not recognized as an internal or external command, 
operable program or batch file.

我尝试了几种方法来调用winsat.exe:

  1. 直接通过指定调用它"winsat.exe"ProcessStartInfo.FileName.它失败了Win32Exception:The system cannot find the file specified

  2. 如上所述,使用完整路径 - @"c:\windows\system32\winsat.exe".它失败并出现同样的错误.

  3. 以系统管理员身份运行代码.它仍然失败.

  4. 如编码示例中那样调用winsat.exe.它像我之前解释的那样失败了.

有趣的是,从代码启动的命令提示符只能在c:\ windows\system32中看到.dll文件.

有谁知道为什么winsat.exe无法启动System.Diagnostics.Process?有没有我误解的限制?

谢谢,

雷克斯

c# system.diagnostics process wow64

6
推荐指数
1
解决办法
5076
查看次数

标签 统计

c# ×1

process ×1

system.diagnostics ×1

wow64 ×1