Shutting down Windows XP when no users are logged on

0 Likes

I work at the University of Copenhagen - Faculty of Life Sciences - Danish Centre for Forest, Landscape and Planning. We have a lot of student computers running Windows XP (managed by ZfD 7). When the students have finished using the computers they tend to just log off leaving the computers running on full power (often over nights or weekends) instead of shutting them down.



But with a little tweaking it is possible to shut down a computer if no user has been logged on for 10 minutes.



We also do weekly automated ZEN imaging and the tweak is also a great way to close the computers after the imaging schedule.



Here is the trick:



  1. Open regedit and locate the key:

    [HKEY_USERS\.DEFAULT\Control Panel\Desktop]

  • Look for the name SCRNSAVE.EXE and change the value to C:\WINDOWS\mysd.cmd

  • Make sure that ScreenSaveActive is set to 1.

  • Set ScreenSaveTimeOut to whatever you prefer (600 = 10 minutes).


  • Now, create a file called mysd.cmd and save it in C:\WINDOWS\.

  • Insert the following into the file (it is all in one line):

    C:\WINDOWS\system32\tsshutdn.exe 1 /SERVER:%COMPUTERNAME% /DELAY:1 /POWERDOWN


  • Log off, wait 10 minutes, and the computer will power off.


You can, of course, use ZENworks to push both the command file and the registry settings. Very fast, simple and easy. This method will work for Windows XP SP3 (and probably also SP2). I used to do it another way on XP SP2. But Microsoft changed a few things in SP3, making my old method unusable. (Look below for the old method.)



For debugging purposes you can set SCRNSAVE.EXE to CMD.EXE and ScreenSaveTimeOut to 10. Log off and wait 10 seconds and a command prompt will open. You can now test different commands.



If you start taskmgr.exe you can see what user is initiating the process. Try starting notepad.exe or mspaint.exe and you will notice that the SYSTEM is the owner of the process. Try using the command:
shutdown.exe -s -t 05
and you will get the message: A required privilege is not held by the client. And that is so, even if you have assigned SYSTEM the right to shutdown the computer (Control Panel > Administrative Tools > Local Security Settings > Local Policies > User Right Assignment > Shut down the computer). You can’t even use the runas command to run shutdown.exe as another user (that was possible in SP2).



Old Method used for XP SP2

Here is the "old" method that I used for Windows XP SP2 with ZENworks:


  1. Edit the registry the same way as mentioned above

  • Create a simple NAL application called: MYSD

  • The NAL application just run: C:\WINDOWS\system32\shutdown.exe with the parameter -s -t 05. Assign the NAL application to the workstation (the NAL Window).

  • mysd.cmd should look like this:

    Nalwin.exe : /A=MYSD.MYAPPS.MYOU /H

    (where MYAPPS.MYOU matches your environment)

This will launch your NAL application (which just shuts down the computer). The application is executed in the security context of the Workstation Manager. As I wrote earlier, this method does not work with SP3.



Right now I am working on a way to make the computer install Windows updates (if any) before shutting down. If I find a method for doing so, I will get back with an update to this post.



If you know a more elegant way to shut down a computer where no users are logged on, post a comment to this tip or email me: anma(at)life(dot)ku(dot)dk



All suggestions will "trigger" a big beer the next time you come to Copenhagen



Best Regards, Anders Martinusen

Labels:

How To-Best Practice
Comment List
Anonymous
Parents
  • As a secondary school we also have the same problem and searched a lot for a solution. The way described is a nice, simply way to shutdown, but there are - in our school environment - some disadvantages:
    - It will shutdown, doesn't matter of the student is still there. He can’t do anything to stop the process.
    - It's not handy when students come in a classroom and some Pc's are down en some are running in a classroom. Or some Pc's shutdown during the lessons.

    So we searched for a tool that could shutdown the system(by groups of pc's) on a specified time but first display's during xxx seconds a warning to the user. So when he is still there he can stop the shutdown process!
    We find a nifty freeware tool: Slawdog SmartShutdown Classic (www.slawdog.com/.../index.aspx.)

    After installing it we did al the settings we want. After that we exported the registry settings and created a ZENworks application to distribute the settings and the program. We now only use the shutdown feature of this product, but is can also be used to start up or suspend a system. In combination with the workstation groups there a lot of flexibility how and when to used it!
Comment
  • As a secondary school we also have the same problem and searched a lot for a solution. The way described is a nice, simply way to shutdown, but there are - in our school environment - some disadvantages:
    - It will shutdown, doesn't matter of the student is still there. He can’t do anything to stop the process.
    - It's not handy when students come in a classroom and some Pc's are down en some are running in a classroom. Or some Pc's shutdown during the lessons.

    So we searched for a tool that could shutdown the system(by groups of pc's) on a specified time but first display's during xxx seconds a warning to the user. So when he is still there he can stop the shutdown process!
    We find a nifty freeware tool: Slawdog SmartShutdown Classic (www.slawdog.com/.../index.aspx.)

    After installing it we did al the settings we want. After that we exported the registry settings and created a ZENworks application to distribute the settings and the program. We now only use the shutdown feature of this product, but is can also be used to start up or suspend a system. In combination with the workstation groups there a lot of flexibility how and when to used it!
Children
  • Hi sra,

    Thanks for your input. I have a few comments:

    - It will shutdown, doesn't matter of the student is still there. He can’t do anything to stop the process.
    That will never happen. Remember that the tsshutdn command only be run if nu user has been logged on for 10 minutes. And when the tsshutdn command is issued it is no longer possible to log on, so it will never conflict with a user logon.

    - It's not handy when students come in a classroom and some Pc's are down en some are running in a classroom.
    It not a problem for us, that the pc's are shutdown (We save power when the pc's are turned off). Furthermore the pc will boot up in 60-90 seconds.

    Or some Pc's shutdown during the lessons
    As mentioned earlier that will never happen, because the shutdown command will never be issued if any users are logged on.

    Thanks for the tip about the freeware tool. I will take a closer look at it.

    Remember that you can always shutdown a system with a user logged on. You can do that with a ZENworks computer policy (scheduled command). You can combine the shutdown with a user warning or even give the user the possibility to abort the shutdown (if you use a tool like this: www.novell.com/.../17146.html)
Related Discussions
Recommended