I am trying to write a program that will automate some setup for new computers at my job. One of the tasks is changing power options for Windows 7. I am trying to run a command that imports a power configuration file and returns the string output which contains a GUID to a variable. When I run the program, it does not return any value to my string. I'm sure I'm messing something up, can someone look and help? Here is my code:
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);
}