I would like to reboot Windows Server 2003 every night.
If I use "shutdown -r", this work well only if no user is connected to the console, or if the user connected doesn't have any open document (for example notepad asks permission before closing). If a user is connected to the console but the session is locked, this also causes the reboot to fail.
If I use "shutdown -r -f" this works everytime, but no application offers the opportunity to close nicely. They are killed. Not nice.
I also tested psshutdown but didn't get the result I wanted.
I also tested to first logoff the console user with "psshutdown -o" but had the same same problem. Then I tested using "psshutdown -o" first and 20 seconds later "psshutdown -o" but the second one exit with an error because an action is already in progress.
In every case, if I push the physical power button, Windows closes nicely in (nearly) every cases. So this is possible.
I am searching for a way to:
- Politely ask applications to close
- After a delay, kill the other ones or emulate the action of the power button (probably with ACPI)