views:

57

answers:

3

When I

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

It outputs:

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

Translated to English:

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

Even when running as admin.

A: 

Set the WorkingDirectory to the path energy.dll and powercfg.exe is located.

Ruel
it didn't work for me
Jader Dias
try copying the dll to windows\system32 ugly but mostly fixes it...
Mario The Spoon
@Mario the dll is already there
Jader Dias
A: 

The error message seems to be generated by the program itself, a system generated message would look different. Is there any command line argument or other configuration for powercfg.exe where it will load it's dll's?

Or perhapse any hint in the manual of powercfg.exe where it will look for it's dll's .

hth

Mario

Mario The Spoon
Here is the command help: http://technet.microsoft.com/en-us/library/cc748940(WS.10).aspx
Jader Dias
No, there is no way of passing dll paths through command line
Jader Dias
+1  A: 

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:

  • Running Visual Studio 2010 as Administrator
  • Targeted .NET 4 Client Profile
  • Compiled both x86 and Any CPU binaries
  • Computer is running Windows 7 x64
Jesse C. Slicer
@Jesse, the culprit is the argument "-energy" which uses the "energy.dll". I didn't include this argument at the time you tested it, but now I edited the question. My environment is the same as yours.
Jader Dias
I did put that argument in there which is why I revised my answer. It applies as written.
Jesse C. Slicer
It began to work, but I don't know what caused the problem or solved it
Jader Dias
Congrats! And... yikes!
Jesse C. Slicer