8
1
Windows has the command shutdown /t
to shutdown or restart the computer after a certain delay. A pending shutdown can be aborted with shutdown /a
.
But how can I determine whether and when a shutdown is currently pending or scheduled, without aborting it?
Shutdown.exe will record events in the Windows SYSTEM Event log with a Source=User32. When a Shutdown command is issued with a timeout of > 120 seconds, event ID 1074 is logged. – DavidPostill – 2016-01-19T11:02:17.403
I can find this message in the event log. But it doesn't say when the restart is scheduled for. It just tells the user and reason. – ygoe – 2016-01-19T11:06:41.013
You need to know the time of the pending shutdown? Please add this important information to your question (you have just invalidated the answer I was writing :/) – DavidPostill – 2016-01-19T11:08:22.363
Anything useful from the
– Hastur – 2016-01-19T11:12:14.690-d
option? Shutdown. Maybe you can find useful the Shutdown Event Tracker.I have added the information to the question.
/d
specifies the shutdown reason, which I did. This information was recorded in the event log. But not the timeout from/t
. Shutdown Event Tracker does not seem to be useful. It does not show the timeout, and it needs to be set up in advance. – ygoe – 2016-01-19T11:17:35.227Can't help with the time, but from a related Q+A on SO you can detect whether a shutdown is pending... the safest is to run
– TripeHound – 2016-01-19T11:50:14.850shutdown /a
which will respondUnable to abort the system shutdown because no shutdown was in progress.(1116)
and set a non-zeroERRORLEVEL
if no shutdown is scheduled (or nothing and zeroERRORLEVEL
if one was).Just dumped registry on a Windows 7 box before and after
shutdown /r /t 10000
and there's precious little difference: a shuffling inSoftware\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSavePidlMRU\*
, some bytes tweaked inSoftware\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{CEBFF5CD-ACE2-4F4F-9178-9926F41749EA}\Count
). – TripeHound – 2016-01-19T12:01:35.020@TripeHound `/a' will abort an existing shutdown. The OP doesn't want to do that. – DavidPostill – 2016-01-19T12:29:56.003
@DavidPostill As noted on the linked question, you can also use
shutdown /r /t _large-number_
which will give an error if a shutdown is already pending (and if it wasn't, gives you time to cancel it). – TripeHound – 2016-01-19T12:42:51.167@TripeHound I know. See my answer ;) – DavidPostill – 2016-01-19T12:56:25.683