Click here to Skip to main content
15,892,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to know the code to shutdown a computer...I want to create an app that has ths feature plz help..Thanks in advance...
Posted

There are a number of ways to do this.

The quickest solution is to use Process.Start("shutdown","/s 0");

For managed code, try WMI classes.
E.g.
ManagementClass mcWin32 = new ManagementClass("Win32_OperatingSystem");
Then invoke Win32Shutdown and shutdown the system.
You would need certain priveleges to access the method above.


For a solution that uses unmanaged code, try
Shut Down, Restart, Log off or Lock your computer in C#[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900