When Windows restarts for automatic updates in the middle of the night, some applications reopen without user intervention. This appears to be using features like SHUTDOWN_RESTARTAPPS
in the dwShutdownFlags flags.
Is it possible to invoke a restart using SHUTDOWN_RESTARTAPPS
or any of the various other SHUTDOWN_*
flags from PowerShell? I see nothing in the Restart-Computer cmdlet, but don't fancy writing C++ just for this.
The simplest powershell solution is to use the cmd line
shutdown /g
command from within your script. That will restart any application that has already registered itself for restart.There's an open request on github to the PowerShell team to add this to
Restart-Computer
which you might want to follow here https://github.com/PowerShell/PowerShell/issues/12106Have you tried using a Scheduled Task that is triggered after a system reboot? perhaps one to check for running services or apps with a powershell script and restart any that failed. You could try this by just calling the executable from a powershell script or module. Maybe something using get-service or get-process?