8/21/2019 A System Shutdown Is In Progress.(1115)
I have a cmd script that will execute a set of patches, and it's designed to abort if a reboot is required to avoid patching issues. I'd also like to extend the script to abort if a reboot is scheduled (E.g. via the 'shutdown' command) in order to avoid reboots mid patch if possible. Unfortunately I haven't managed to find a way to detect this apart from attempting to schedule another shutdown, which results in:
A system shutdown has already been scheduled.(1190)
While I could theoretically use this I don't think it would be good practice to scare logged in users every time I needed to check for a scheduled reboot. What I really need is a way to QUERY the state modified by the 'shutdown' command.
Is this possible? I'll be happy with really any solution that doesn't involve me having an application running permanently on the system to catch the shutdown events (which I don't think even get sent around until the shutdown is actually triggered)
However, when I replace the default restart command with shutdown /a && shutdown /r /t 5 shutdown /r /t 5 which should try to abort all pending shutdowns and then start a shutdown, or start a shutdown if one is not in progress, it 'aborts' successfully, then fails to restart with 'A system shutdown is in progress.(1115)'. This has something. 1115 (0x45B) A system shutdown is in progress. 1116 (0x45C) Unable to abort the system shutdown because no shutdown was in progress.
skaffman
348k8888 gold badges745745 silver badges730730 bronze badges
IficatorIficator
4 Answers
I have the same problem, I searched all over, but did not find anything useful.
Eventually I just started messing around with different things I could think of. I can think of two workarounds for our problem.
The event viewer can tell you that a shutdown has been scheduled, but not WHEN it was scheduled.
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. If the scheduled shutdown is more recent than either the most recent cancellation or shutdown then there is one in progress.The Event IDs are: 1074 for a started scheduled shutdown, 1075 for a canceled scheduled shutdown, under Windows Logs/System12 for system start up13 for system shutdown(all under Windows Logs/System)
I was too lazy to do this in a batch file, I know it is possible though.
So this is what I ended up doing:Rather than schedule a shutdown, just try to abort it. If no shutdown is in progress it will throw an error (Unable to abort the system shutdown because no shutdown was in progress.(1116)). Much better I think than freaking out a user by scheduling a shutdown.
Here is a copy of the code I wrote for a simple auto shutdown script, it toggles between cancelling and starting a scheduled shutdown.
EDIT - I am revisiting this answer as I have more info to add.
The Above solution will detect if a shutdown has been scheduled via the shutdown.exe command using the /t argument.
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 below is in PowerShell, but you can write a batch file to do the same.
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.
Liam
16.8k1616 gold badges7979 silver badges133133 bronze badges
JosephJoseph
I suppose you could use the Task Scheduler API to enumerate the scheduled tasks and see if any of them invoke shutdown.exe. But I'm not sure that's robust. There are probably multiple ways to schedule a shutdown.
Adrian McCarthyAdrian McCarthy
33k1010 gold badges8585 silver badges136136 bronze badges
Another way to do this, if your script is setting the shutdown, is to save the %date% and %time% variables into global environments using setx command. Then you can check these variables on the next time that the script is called.
MarceloMarcelo
Maybe you can try to initiate a shutdown by calling ExitWindowsEx with a large grace period and check for the return code ERROR_SHUTDOWN_IS_SCHEDULED and call AbortSystemShutdown immediately if ExitWindosEx return success (indicating you successfully scheduled a shutdown)
VagausVagaus
Not the answer you're looking for? Browse other questions tagged windowswinapisystem-shutdown or ask your own question.This is attempt to reboot a MS Windows Server 2008 R2. I tried to use 'Shutdown.exe' and also 'PSShutdown.exe', but both methods failed.This is how I tried: a. I logged as member of domain admin on my laptop (Windows 7) b. open command prompt, type 'psexec w2k8r2Server cmd'; connection successfully *w2k8r2server is the target server c. in c:windowssystem32, type 'shutdown -r -f' A system shutdown is in progress. (1115) However, system is not rebooting. Later I tried the PSShutdown, same result. According to some forums, I even 'pskill winlogon' and then 'pskill trustedinstaller'. still same result. Besides Remote registry service, any services, such as, remote administration and firewall ports need to open? Please help. Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |