Click here to Skip to main content
15,908,776 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
hello guys.

sometimes when i turn on pc and after many hour ( 3-4 ) when i want to shut down pc i see this screen

i want to make mini program to force shut down computer after 4 hour, without ask Force shut down - Cancel ( in img ).?

help me
Sergey Alexandrovich Kryukov 6-Jan-15 17:51pm    
What have you tried so far?
Such things are explained in very many places on the Web. It's just so happened that I have few batches for my convenience, including one for local computer hibernation.

1 solution

The simplest way would be something like this:
System.Diagnostics.Process.Start("shutdown", "/s /t 240");

Forcing closing of currently running applications without asking can be done using the option "-f".

For exact command line parameters, run "shutdown" on your system and see how it use its help, following the instructions. You can also see this:[^].

You can also use Windows API or System.Management (WMI), according to the answers to this question:[^].

Share this answer
Agent__007 6-Jan-15 22:19pm    
Sergey Alexandrovich Kryukov 7-Jan-15 1:43am    
Thank you, James.

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