Hibernate computer with a timeout from command line on Windows 7
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 3 Looping
--
Chapters
00:00 Question
00:43 Accepted answer (Score 91)
01:18 Answer 2 (Score 46)
01:43 Answer 3 (Score 13)
01:59 Answer 4 (Score 10)
02:36 Thank you
--
Full question
https://superuser.com/questions/83437/hi...
Answer 1 links:
[How do I make a batch file wait / sleep for some seconds?]: https://superuser.com/questions/48231/wi...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#windows7 #commandline #hibernate
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 3 Looping
--
Chapters
00:00 Question
00:43 Accepted answer (Score 91)
01:18 Answer 2 (Score 46)
01:43 Answer 3 (Score 13)
01:59 Answer 4 (Score 10)
02:36 Thank you
--
Full question
https://superuser.com/questions/83437/hi...
Answer 1 links:
[How do I make a batch file wait / sleep for some seconds?]: https://superuser.com/questions/48231/wi...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#windows7 #commandline #hibernate
#avk47
ACCEPTED ANSWER
Score 94
I don't believe you can set a time for hibernation, unfortunately.
Try:
ping -n 20 127.0.0.1 > NUL 2>&1 && shutdown /h /f
The ping
is a hackish way of delaying the action. -n 20
should wait for 20 seconds.
(the double &&
will allow you to do a Ctrl+C to cancel the operation, but if you use a simple &
then pressing Ctrl+C will only break the timer and then continue to shut down)
ANSWER 2
Score 50
You could also consider using "timeout" or "waitfor" commands in a similar manner.
timeout /t 20 /NOBREAK > NUL && shutdown /h
or
waitfor NUL /t 20 || shutdown /h
More here: How do I make a batch file wait / sleep for some seconds?
ANSWER 3
Score 13
I use the following:
sleep 20 && shutdown /h /f
Or this if I want it off at a certain time:
At 22:30 shutdown /h /f
ANSWER 4
Score 9
I think that it complains about time. Just put shutdown /h
and it should work.