Click here to Skip to main content
15,891,852 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

http://cdn.techdows.com/wp-content/uploads/2011/11/force-shutdown-windows.png

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

help me
Posted
Comments
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.
—SA

1 solution

The simplest way would be something like this:
C#
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:
http://technet.microsoft.com/en-us/library/bb491003.aspx[^].

You can also use Windows API or System.Management (WMI), according to the answers to this question:
http://stackoverflow.com/questions/102567/how-to-shutdown-the-computer-from-c-sharp[^].

—SA
 
Share this answer
 
v4
Comments
Agent__007 6-Jan-15 22:19pm    
+5d!
Sergey Alexandrovich Kryukov 7-Jan-15 1:43am    
Thank you, James.
—SA

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