I agreed, we can shut down cleint machines programatically. but suppose my machine is configured with Windows server 2008 r2. to shut down any server machine, is not easy as compare to normal client operating systems machine. since we need to stop services,stop running processes and at the end we need to give confirmation to the os that this shutdown process is "planned" for shut down event tracker. so can we do that from c# console application?. What programe i have to do for this?
Edited: I am thankfull for all answers. But one thing i missed while writing the question, this shutdown must perform only when machine is unattended for 120 mins. so is there any another process where i can check the attendance-unattendace of machine ? so that i would call shutdown process.
You can do so using the shutdown.exe
command of Windows:
Process.Start("shutdown.exe", "/l /t:0");
If you simply want to get rid of the dialog for entering a shutdown reason you can configure your Registry accordingly:
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Reliability]
"ShutdownReasonOn"=dword:00000000