仕事で新しいコンピューターのセットアップを自動化するプログラムを作成しようとしています。タスクの 1 つは、Windows 7 の電源オプションを変更することです。電源構成ファイルをインポートし、GUID を含む文字列出力を変数に返すコマンドを実行しようとしています。プログラムを実行すると、文字列に値が返されません。私は何かを台無しにしていると確信しています。誰かが見て助けてもらえますか? これが私のコードです:
if(chkPowerSettings.Checked == true && radioDesktop.Checked == true)
{
//Establish the path to the power configuration file
string DesktopFileName = "WTCPowerDesktop.pow";
string CFGFileSource = @"\\\\ops-data\\Apps\\Builds";
string TargetPath = @"c:\\";
//Creates the strings for the whole path
string source = System.IO.Path.Combine(CFGFileSource, DesktopFileName);
string destination = System.IO.Path.Combine(TargetPath, DesktopFileName);
//Copies the file, the true will overwrite any already existing file
System.IO.File.Copy(source, destination, true);
System.Diagnostics.ProcessStartInfo importCFG = new System.Diagnostics.ProcessStartInfo("cmd","/c" + "powercfg –import C:\\WTCPowerDesktop.pow");
importCFG.RedirectStandardOutput = true;
importCFG.UseShellExecute = false;
importCFG.CreateNoWindow = false;
System.Diagnostics.Process runImport = new System.Diagnostics.Process();
runImport.StartInfo = importCFG;
runImport.Start();
string PowerCFGResult = runImport.StandardOutput.ReadToEnd();
MessageBox.Show(PowerCFGResult);
}