Mahobo
Mahobo

Reputation: 181

energy.dll is missing, when starting powercfg from code

This is an addition to an Old Thread

How to start `powercfg.exe -energy` from a .NET app?

I'm trying to run powercfg /BatteryReport. It throws an error

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

This is the code I used:

using (Process JS = new Process())
        {
            string output = "\"" + runfrom + "\\" + msn + ".html\"";
            JS.StartInfo.Arguments = (@" /k powercfg /BatteryReport /output " + output);
            JS.StartInfo.FileName = (@"cmd.exe");

            MessageBox.Show(JS.StartInfo.FileName + JS.StartInfo.Arguments);
            JS.Start();
            JS.WaitForExit();
        } 

I receive the energy.dll error as mentioned above. First I ran the powercfg command directly. I changed to the script above, to see whats going on. When I do a DIR on Windows\System32 in the command box, opened by my code, there are 2672 files in there. When I open up a new command box and do a DIR on Windows\System32, there are 3866 files. Any idea what kind of witchcraft this is?

Upvotes: 2

Views: 2488

Answers (0)

Related Questions