How to Ensure Scheduled Reboot Works Even When Users Have Apps Open?
Asked by
_sensible_hats
I'm facing a challenge with my scheduled reboot task for computers. The command I'm using is `shutdown /r /f /y /t 0`, and it usually works perfectly. However, there are times when a user forgets to log out and leaves an application running, like a video on loop. Although the reboot task says it completed successfully, the computer doesn't actually reboot because of the active application.
I'd love to hear some suggestions on how to handle this situation since educating users hasn't been effective and I need a more reliable solution.
Answers
What works for me is using PowerShell to do the scheduling. Run the task as the system account, and it hasn't failed me yet. You can set it to reboot at a specific time, like Sundays at 2 AM. Hereโs a little script you can set up:
```powershell
$Trigger= New-ScheduledTaskTrigger -Weekly -DaysOfWeek Sunday -At 2AM
$User= "NT AUTHORITYSYSTEM"
$Action= New-ScheduledTaskAction -Execute "C:windowssystem32windowspowershellv1.0powershell.exe" -argument '-command restart-computer -force'
Register-ScheduledTask -TaskName "Sunday 2AM Reboot" -Trigger $Trigger -User $User -Action $Action -RunLevel Highest โForce
```
Just modify the trigger to fit your needs!
Reply to this answer
Have you considered modifying your script to log off all users before rebooting? If you force everyone to log off, it should clear any active applications. That might solve the issue of your scheduled task reporting success without actually rebooting the machines.
Peregrine: I initially thought that if `shutdown -r` wouldnโt work with active apps, then `shutdown -l` wouldnโt either. But it seems like it actually works during testing. Good tip!
Reply to this answer
Add your answer
Answers are reviewed before publication.
chisel+edge: This is exactly what I needed! Thanks a bunch!