Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:

  1. Politely ask applications to close
  2. After a delay, kill the other ones or emulate the action of the power button (probably with ACPI)
share|improve this question

3 Answers 3

How about something like: shutdown /t 60 /f

The help for shutdown /f say it implies /t xx is greater than 0. This should give the user 60 seconds to turn things off prior to restart.

share|improve this answer
    
This only resolve the case when a user is just in front of the server. This don't resolve the problem when the session is locked, when the user is away. And, more important, this just kill every application, even those which could close nicely if asked. –  Gregory MOUSSAT Feb 8 '12 at 22:15
    
How about using shutdown /L to log off the user and then shutdown /r to restart it? –  uSlackr Feb 8 '12 at 22:34
    
shutdown /l have exactly the same problems (as psshutdown -o) –  Gregory MOUSSAT Feb 9 '12 at 11:30
up vote 1 down vote accepted

I found a nice workaround: tsshutdn.exe\

Even if Terminal Server is not enabled, this cleanly close every possible programs, and kills uncooperative ones.

Look at tsshutdn.exe \? for command line options.

share|improve this answer

Is this a terminal server, meaning does it have the terminal server role installed? If so, this would be another option.

http://technet.microsoft.com/en-us/library/cc773312(WS.10).aspx

Additionally, I haven't tested it, but this custom app (poweroff) looks like it might be worth a try as well.

http://users.telenet.be/jbosman/applications.html

share|improve this answer
    
This setting don't change anything because "-f" just kill every applications without delay. –  Gregory MOUSSAT Feb 9 '12 at 20:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.