如何开始从.NET应用程序'的Powercfg.exe -energy`?应用程序、NET、energy、exe

2023-09-03 01:44:59 作者:犯贱请绕道

当我

using (var process = new Process
{
    StartInfo = new ProcessStartInfo
    {
         FileName = "powercfg.exe",
         Arguments = "-energy",
         RedirectStandardOutput = true,
         UseShellExecute = false,
    }
})
{
    process.Start();
    process.WaitForExit();
}

它输出:

有一个藏书德Diagnóstico日Eficiência日Consumo德能源公司(energy.dll)NAO    颇得SER carregada。

A biblioteca de Diagnóstico de Eficiência de Consumo de Energia (energy.dll) não pôde ser carregada.

翻译成英文:

能源消耗效率诊断库(energy.dll)不能被加载。

The Energy Consumption Efficiency Diagnostic library (energy.dll) couldn't be loaded.

即使运行的管理。

推荐答案

我怕我不能重复你的结果;我得到的结果文件的预期。但是,如果有帮助,也许是我的测试参数可以帮助你缩小了可能会在您的环境的罪魁祸首:

I'm afraid I cannot duplicate your results; I get the results file as expected. But if it helps, perhaps my testing parameters will help you narrow down what may be the culprit in your environment:

在运行Visual Studio 2010中以管理员身份 目标.NET 4客户端配置文件 在编译x86和任何CPU二进制文件 在计算机运行的是Windows 7 64位系统