We help IT Professionals succeed at work.

Reboot script for Citrix server warn users first

jpletcher1
jpletcher1 asked
on
We have Presentation Server 4.5, but not the edition where I can schedule reboots ( I assume because I don't have a Resource Manager).  I'd like to schedule reboots of the server weekly.  I see there are a couple options, shutdown.exe and tsshutdn.exe.  Are either of these better to use if I want to notify end users ahead of time before the reboot?  Say 15 minutes?  I know you can use comments with the shutdown.exe command.  I'd also like to disable logins when the 15 minutes starts or even before that.  I see there is a command to do this as well from the Windows TS side, but not sure if that translates through to Citrix.  

Here is an example of something I found and I'm not sure if it will work or not for my scenario.

change logon /disable
logevent -S W -C 7311 -e 3603 "AUTOMATED SERVER REBOOT IN 12 MINS"
msg * Please log off and save your work. Automated Scheduled Reboot. The Citrix server is going down in 12 mins.
sleep.exe 300
msg * Please log off and save your work. Automated Scheduled Reboot. The Citrix server is going down in 7 mins.
sleep.exe 240
msg * Please log off and save your work. Automated Scheduled Reboot. The Citrix server is going down in 3 mins.
sleep.exe 60
net stop lpdsvc
net stop spooler
sleep.exe 120
del c:\WINNT\System32\spool\PRINTERS\*.* /q
change logon /enable
tsshutdn 30 /DELAY:0 /REBOOT
Comment
Watch Question

Lead Technical Architect
CERTIFIED EXPERT
Commented:
That would work for you.

However, there are a couple of things you need to be aware of, and a couple of inconsistencies in the script:

Logevent.exe was a Windows 2000 resource kit tool. I've never tried it on 2003, but have read a few reports suggesting it may not work properly;

Sleep.exe is also a resource kit tool, so will also need to be added. You might want to look into the values for sleep.exe too, as if they're seconds, then 300 = 5 mins and 240 = 4 mins so the values being written are wrong.

Tsshutdn works in seconds - so that last line will actually run with a 30s notification and then reboot.

Personally, as well as stopping the print spooler, I had a preference for deleting any old/stuck print jobs too.

Author

Commented:
Thanks.  Yes the logevent.exe command does not work in Windows 2003 and I had to get the resource kit for the sleep.exe.  

When we stop our print spooler it has to stop the citrix print managment service, and that one doesn't always shut down gracefully, so I think I'll remove the part at the end to stop services and clean the print folder.

Thanks for the input.

Author

Commented:
Thanks for the added info.