System.Diagnostics.Process[] processes =
Code
System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process
processParent in processes)
{System.Diagnostics.Process[] processNames =
System.Diagnostics.Process.
GetProcessesByName
Code
(processParent.ProcessName);
foreach (System.Diagnostics.Process
processChild 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
Answers
Know the answer? Post it. Somebody with the same question will find it here.