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.
2 Answers
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.
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!
This is exactly what I needed! Thanks a bunch!

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!