Quand jeComment commencer `-energy` powercfg.exe à partir d'une application .NET?
using (var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "powercfg.exe",
Arguments = "-energy",
RedirectStandardOutput = true,
UseShellExecute = false,
}
})
{
process.Start();
process.WaitForExit();
}
Il produit:
peut être perçue La bibliothèque Efficacité de la consommation d'énergie de diagnostic (energy.dll) non .
Traduit à Inglês:
La consommation Efficacité énergétique bibliothèque de diagnostic (energy.dll) n'a pas pu être chargé.
Même lors de l'exécution l'admin.
le seul problème se produit lors de l'exécution de l'application de .NET, Quand je l'invoquons de la ligne de commande, il fonctionne normalement –
Pourquoi d vous avez la UseShellExecute = false? – dthorpe
@dthorpe RedirectStandardOutput = '' true' nécessite UseShellExecute = –