![]() Note: this will not return true if a reboot in scheduled using shutdown.exe, it will only return true if Windows says your computer need to be rebooted. Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending' The below is in PowerShell, but you can write a batch file to do the same. If you need to determine if Windows has schedule a shutdown (as it does automatically after some Windows Updates) then there is a registry entry that is set which you can query. The Above solution will detect if a shutdown has been scheduled via the shutdown.exe command using the /t argument. If you want to change the timer value, right-click the shortcut icon, select Properties, and change the second value in the Target field. ![]() To cancel the timer, you can create a second shortcut by using shutdown -a or by typing the shutdown -a command in the command prompt. Set /p choice=Shutdown in how many minutes?ĮDIT - I am revisiting this answer as I have more info to add. Whenever you double-click the shortcut, the timer will run. Here is a copy of the code I wrote for a simple auto shutdown script, it toggles between cancelling and starting a scheduled shutdown. Much better I think than freaking out a user by scheduling a shutdown. If no shutdown is in progress it will throw an error (Unable to abort the system shutdown because no shutdown was in progress.(1116)). Rather than schedule a shutdown, just try to abort it. I was too lazy to do this in a batch file, I know it is possible though. If the scheduled shutdown is more recent than either the most recent cancellation or shutdown then there is one in progress.ġ075 for a canceled scheduled shutdown, under Windows Logs/System One idea is to query the event viewer for the most recent system shutdown, the most recent scheduled shutdown, and the most recent cancellation of a scheduled shutdown. The event viewer can tell you that a shutdown has been scheduled, but not WHEN it was scheduled. I can think of two workarounds for our problem. I have the same problem, I searched all over, but did not find anything useful.Įventually I just started messing around with different things I could think of.
0 Comments
Leave a Reply. |