System.Diagnostics.Process[] processes =
System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.ProcessprocessParent
in processes){
System.Diagnostics.Process[] processNames =
System.Diagnostics.Process.
GetProcessesByName
(processParent.ProcessName);
foreach (System.Diagnostics.ProcessprocessChild
in processNames){
try{
System.IntPtr hWnd =
processChild.MainWindowHandle;
if (IsIconic(hWnd)){
ShowWindowAsync(hWnd, SW_RESTORE);
}
SetForegroundWindow(hWnd);
if (!(processChild.MainWindowTitle.Equals(
this.Text))){
processChild.CloseMainWindow();
processChild.Kill();
processChild.WaitForExit();
}
}
catch (System.Exception exception){
}
}
}
Full code can be found: http://www.codeproject.com/csharp/timercomputershutdown.asp
I am only using this part of the code to shut down, however, i am only restarting the computer, not powering down for good.
Can anyone shed some light onto this?
Thanks
Replies
Know the answer? Post it — somebody with the same question will find it here.