Programming to force shut down(Windows)

sohel

Beta member
Messages
1
Hi, i want to make a program using C# which will force the shut down in windows. How can i do it? I have no idea about how the shut down works in windows.
 

j031

~~~~~~~~
Messages
5,556
Location
Wales
You can run:

shutdown -f -t 10 -s

to shutdown a computer running windows, so you could probably just run that as a system command.
 

berry120

Fully Optimized
Messages
3,434
Location
UK
As above, I'd recommend just putting
Code:
shutdown -f -t 10 -s
into a batch file and running that. C# is absolutely overkill for this purpose!

The -f in the command is used to force shutdown (even if other programs aren't responding or try to hang.) The -s bit is the bit that's telling it to shut down and the -t 10 means do it in 10 seconds.
 
Top