【发布时间】:2016-07-27 21:50:21
【问题描述】:
当我
using (var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "powercfg.exe",
Arguments = "-energy",
RedirectStandardOutput = true,
UseShellExecute = false,
}
})
{
process.Start();
process.WaitForExit();
}
它输出:
A biblioteca de Diagnóstico de Eficiência de Consumo de Energia (energy.dll) não pôde ser carregada。
翻译成英文:
无法加载能源消耗效率诊断库 (energy.dll)。
即使以管理员身份运行。
【问题讨论】:
-
这个问题只发生在从.NET执行应用程序时,当我从命令行调用它时它运行正常
-
为什么会有 UseShellExecute = false?
-
@dthorpe
RedirectStandardOutput = true需要UseShellExecute = false
标签: .net windows windows-7 process powercfg