Shutdown idle computers

How can I shut down idle windows XP pro workstations on a Win2003 domain? I have tried screensaver options, some freeware ones (most are useless), some vbscripts. Unfortunately powercfg or shutdown.exe don't do the trick. As we have many users logging off, but not shutting down, I'm looking at ways to conserve power as these workstations often will stay powered on for days or even weeks if the users aren't there.
Does anyone know of a script/software I can schedule from one of the servers, say at 6pm, that will check inactivity, and if the computer hasn't been used for at least an hour, shut down? If a user is logged on, it would be important for them to abort.
Thanks in advance of all replies.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Unless there's an option on the motherboard to allow shutdown over the network (which would require some special management software) built into the machines, no way.

Bad move on your part to do so anyway, who knows what the users have running that needs to continue overnight?
I frequently have had processes with very long execution times, and so have many other people I know.
Those you start just before you leave for the night and hope they're done when you get back. Some of them would need to be started on friday afternoon to be completed monday morning.

Your misguided attempt at saving the planet would make my work impossible.
Type in expert-exchange search-- All zones, shutting down remote computer and you will find very useful links like this :

Bm Keshav
You could put a batch file in the all users startup of every system

Try this, save it as a batch file and put it in all users startup, once someone logs in on this machine it will automaticaly set 2 schemes (change the names to your liking)

It will then select scheme 1, you are best to use 2 schemes as not all users are the same and you may not want the hard drive to save power on some systems (if they remote in to the system or something)

I have set these schemes so the monitor powers off after 10 minutes and the hard drive after 3 hours for scheme 1 and just the monitor powers off for scheme 2, change the last line to determine which scheme to use for each PC

You can clean up the batch file to make it display a notice while its running etc, I'll leave that to you, at least you have the basic premise for it with this

You just have to decide how to push this out to all your machines now depending on what sort of solutions your company uses
cd windows
cd system32
Powercfg /c "HRGScheme1"
Powercfg /c "HRGScheme2"
Powercfg /change hrgscheme1 /monitor-timeout-ac 10
Powercfg /change hrgscheme1 /standby-timeout-ac 180
Powercfg /change hrgscheme2 /monitor-timeout-ac 10
Powercfg /change hrgscheme2 /standby-timeout-ac 0
Powercfg /s hrgscheme1

Open in new window

10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

I'm agree with jwenting,
You may prefer to make them go to the Hybrid-Sleep mode so they can restore any on progress work, this will be automatically and its the lowest energy consumption mode.
Read more about this at:

hope this help.

If you want them to shutdown....just create a task  in the task scheduler.

Before doing this create a file using the notepad.exe application. Inside the file put these instructions:

@echo off
shutdown /f /s

Save the file with any name you want something like dailyshutdown.bat (the file extension must end in .bat) and save it to your drive C in the root directory.

Now, In windows xp pro, create a scheduled task:

Start-Accessories-System Tools-Scheduled Tasks.

Once there click on "Add a Scheduled Task".
Click on Next.
Click on Browse and browse for dailyshutdown.bat in your C:\
It will now ask you if you want to perform this task daily, weekly, etc... choose one and click on next
You can configure to run at a specified time.
It will now ask you to provide a username and password (use the administrator credentials).
Click on finish.

That's it.....hope it helps.

I forgot to mention....initially we would create this task on the server and create the .bat (batch) file on the server to tell it to shutdown the computers. The batch file would contain an instruction something like this:
@echo off
shutdown /f /s \\computername

But living in Florida, the lightning capital of the world, we had problems with the power being interrupted and sometimes the client pc's would lose access to the server so we decided to put the task on each one of the individual computers.
Another thing....I disagree with some of the comments above.....a properly secured network depends fundamentally on the "users" following the of these rules means "log off" before you leave.....login off means that you have saved all your work and closed all your programs.....if you lose any broke the rules and you are severely reprimanded. You are endangering the whole company....It is your fault...not the systems administrators fault. Eventually all users will adapt and they will log off before leaving for the day....
powercfg  nor shutdown will do the trick asn the author said. there is a way to change the power scheme remotelly using pstools:

//source :
First of all, get the pstools and set them up. then run
psexec \\[workstation name] powercfg /query
Field Description Value
----------------- -----
Name Home/Office Desk
Numerical ID 0
Turn off monitor (AC) After 20 mins
Turn off monitor (DC) After 5 mins
Turn off hard disks (AC) After 60 mins
Turn off hard disks (DC) After 10 mins
System standby (AC) Never
System standby (DC) After 5 mins
System hibernates (AC) Never
System hibernates (DC) After 20 mins
Processor Throttle (AC) Not Supported
Processor Throttle (DC) Not Supported
that will tell you what the current settings are. After that, you can set the power scheme by doing this:
psexec \\[workstation name] powercfg /setactive "[scheme name]"
It will exit with error code 03, but no worries. Just check your work using the query command above after your changes.

hope this helps.
Shutdown.exe will do the trick even if the user is logged off if it is properly configured in the task. He must use Administrator (of the local machine) credentials.........
canuc0Author Commented:
Thanks for your prompt replies. To address some of the comments:

- The environment is a school, power consumption is an issue due to holidays, etc.
- Students don't have overnight processes running on their computers
- The users don't do the correct thing, and log off or shut down when finished. I have to strongly agree with Bits comments about this.
- We have tried hibernation, but it has caused issues with not waking up in a timely fashion, thus users would unplug the computers, etc. causing even more headaches.
- I have searched ee and google to no luck. Perhaps it can't be done, and I'm 'dreaming', but I'll find a solution!
- Shutdown.exe might be the best option, but I'm hoping to do this with idle state computers.

We do this every day with 530 computers. One of the issues we had was in the morning...when they were being turned on, the traffic bombarding the server trying to establish a connection was very high and with the consecuent delays....fortunately...most of them are Dell's that have the new feature that allows them to be configured to wake-up at any given time during weekdays and weekends...

I'm guessing that you must have tried to schedule a task to run directly the shutdown.exe ....we had problems there thus we created the batch files......

If you run shutdown.exe from a command prompt:

C:\shutdown /?

It will offer you a great amount of options and it works perfectly at shutting down in any scenario....idle...logged on ....logged off..... The only times it has failed is when a computer is hanged for another reason.....
canuc0Author Commented:
perhaps I missed something here - how can you use shutdown command with idle time?
Absolutely........If you configure it through the Schedule task, it even has an option to allow you to configure the run after the computer has been idle XXX amount of time...... so basically: you create a batch file as described above......and then you configure the scheduled task to run the batch file at the hour and min most convenient for you...... It works like a charm .... you cant test it at your own computer at home you can have it turn your computer off after it has been idle for 5min....or you can just decide to configure it to run at a given time ......lets say can actually configure it not to run if the computer is not idle......
canuc0Author Commented:
If I run a shutdown task scheduled on a server, it will run on idle time of the server, not the remote computers I want to use shutdown. In other words, the idle function is part of the scheduler, and not the shutdown command.
What am I missing? How are you doing this with 530 computers and checking to see if each one is inactive before shutting them down?

On another note, found this interesting software, but very pricey:
canuc0Author Commented:
Folks, thanks for all the replies. It's what makes this forum so valuable.
Bits, my apologies, I misread one of your posts that mentioned you "put the task on EACH one of the individual computers" (emphasis mine), not the server's task.
Powercfg, shutdown.exe, pstools all work on the premise of using standby/hibernation and modifying the power scheme. I want to shutdown the computers, not just the hard drive, on idle time.

I'm currently thinking of using a combination of winexit.scr in the Win2k3 Resource Kit to log off on inactivity:
and then use a scheduled script later at night from a server to shut all computers down in an OU:

Any thoughts on this? 'Round about way, but might work...cannot believe there isn't a group policy option to do all this!
BitsBytesandMoreCommented: run the shutdown task scheduled on each individual  CLIENT...NOT THE SERVER....
In other words....just in case I'm confusing you ......: you walk to each pc and create a batch file with this line on it
shutdown.exe /f /s

Then on the same machine you click on Start Schedule a task to run this batch file Start-Programs-Accessories- System Tools - Scheduled Tasks and create a task to run when the computer is idle...(it does it automatically only need to get into the advanced features if you want to configure things like "run task after the computer has been idle for xxx minutes" .....
there is a group policy you should try this download from EnergyStar its free (it seems that doesnt work on vista).
I'd like to add that power schemes do shutdown the PC if configured to hibernate. They go to 0 energy consumption.

"EZ GPO is a free tool for network administrators who run Windows Active Directory and manage client workstations using Group Policy Objects (GPOs). EZ GPO provides Group Policy Objects for centrally configuring power management settings, as they are not native in Windows 2000 or XP. However, power management can be managed through Group Policy on Windows Vista machines. (For this reason, the EZ GPO tool does not work on Vista PCs.)"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You are absolutely right with the 0 energy consumption but the problem with hibernate is that it causes issues when waking up.....especially if you have impatient students that start clicking on things before it's fully awake.....and even still causes issues which eventually will force you to reboot and in a students case horrible...pulling of the cord from the wall socket....ufff..scary stuff..
I just got an idea, just in case shutdown doesnt work on idle state. Use EZ GPO to change the power scheme on all the computer remotelly to turn off most of the devices but not going to sleep or stand by.

this way at the scheduled time, shutdown.exe will definitively run and shut them down.

the other way is to wake on Lan tool(wolcmd) make them wake up then shut them down.
"Wake on LAN (WOL, sometimes WoL) is an Ethernet computer networking standard that allows a computer to be turned on or woken up remotely by a network message sent usually by a simple program executed on another computer on the network."
canuc0Author Commented:
Pepepaco, thanks for the gpo link! May find that useful.
Bits, I can't fathom having to visit each workstation as we have near 400. I haven't tried this, but can't see why you shouldn't be able to copy a scheduled task file (%windir%\tasks) via logon script to each computer. This might be the best answer to the idle question if running on each individual computer. Another solution not mentioned is the possibility of a custom written screensaver.

This week I've tried winexit.scr to log off on inactivity, and it works well. The shutdown script from EE (link above) works. This is my current plan:

1. Wake up computers an hour before students use them. We use WSUS, so this will have the added advantage of doing updates before students arrive.
2. Use group policy to restrict restart and log off commands, so they can only shut down.
3. Copy winexit.scr via login to each XP workstation. On idle, after an hour it will log off whoever hasn't used their computer in that time.
4. Use powermanagement via group policy to shut down monitors and hard drives after an hour and a half, but ensure that a shutdown command will still be able to be run.
5. Run psshutdown from scheduled server task after hours.

Although my original query was how to shut down computers if they were idle, it seems that forced logoffs on inactivity first might be a better option, then shutting down at night from a scheduled task on a server. Power schemes, such as standby have caused me too much frustration, so don't want to use them, as Bits mentioned above as well.
Thanks all for your replies. I'll leave this open for another week in case anyone has any other comments, before accepting a solution.
thanks again,
Hey canuco,
Your plans sound great....when I mentioned "to walk to each pc" was just a figure of speach...I wanted to make my point that you you could initiate the task either from the server or from each pc.....and can copy the tasks and batch files to all computers... for some reason shutdown.exe does not seem to work by itself on the task manager when given the parameters but works great through a batch file...
canuc0Author Commented:
Hi Bits, thanks for the clarifications, afraid I'm too slow to pick up on nuances! lol. I use vbscript primarily because it's much more powerful than batch files, and I can call windows wmi etc. I also have found that any command line options (such as 16 bit) don't run reliably as a scheduled task, thus I us vbs ( as a front to run those commands within, such as the following:
    'strShutdn = "shutdown -s -t 0 -f -m \\" & CompName
    'set objShell = CreateObject("WScript.Shell")
    'objShell.Run strShutdn
where CompName is the name of the computer
Also, if you use the free sysinternals (now MS) file psshutdown, you have more control as it has considerably more options/switches.
Hi canucO,

This thread has become so interesting that I believe that we might have picked up on something. I totally agree with you about the script files. I'm an "Old school" guy and have been doing this since 1983 and at one time was a "Master" with batch files (that's all we had at the time). Vbscript is so much more powerful but old habits are hard to shake off and sometimes (most of the time) I tend to forget the syntaxis and have to look it up and end up sidetracking myself when I see all of the other posibilities of this or that on scripting, bottom line....when I need to get something done in a hurry....I always end up going back to what I remember immediately...a simple command for a batch file. It happens because it was my "first language"

You mentioned in your question that "...shutdown.exe was not doing the trick..." and my first thought was ...Why? "...Just create a simple batch file for it...." and the problem is solved, hell, it's working every day for us. But then when you just mentioned about making a script, that's where you got me thinking again....Why? Maybe a typo? Maybe a bug? And again....I totally agree with you regarding scripts...

I know, we are sidetracking from the original question but it would be interesting to find out why it was not working with your script....... I figure we should ....if we ever get take a look into it.

You made me remember that when we tried it with scripts we did have problems (which I had atributed to the constant power problems that don't overwhelm the UPS of the servers, but definitely creates problems with the cheap UPS's on the clients)...... You might want to review those might just have picked up on a bug......In any case.....try the batch file method toghether with the task manager....I can assure you it works like a charm.....later we can take a look into why it failed with the scripts and systernals (which I love)...... It shouldn't have......but you understand the IT world...we're always in a hurry and there is always something that needs to be done by yesterday.....
canuc0Author Commented:

When I mentioned that powercfg shutdown weren't doing the trick, it was in context of shutting down IDLE computers, which was my original query. I don't currently have any problems with using the shutdown command to SHUT down computers (sorry, I'm not flaming, but emphasing...).

I also grew up on DOS and batch files, so I understand the reluctance to learn new language when something else will work - and quickly. I simply forced myself to start learning vbscript as there were things I couldn't accomplish via batch file. I currently install printers, map drives, copy files, etc. in logon vbscripts. Works a treat. I found the best way to learn it is googling, and picking up snippets/modules from different sources. Modifying and playing around with it is the best 'tutorial'.
By no means am I a vbscript guru! There's a few good ones in EE, though!

Unfortunately, the definition of "idle" for a computer is very vague. According to some, a computer is described as idle when it's processor is not being used by any program.

But, for example, Win32 screensavers determine that a computer is idle if there is no keyboard or mouse input for N minutes regardless of whether or not the CPU has a high load.

Assuming that by "IDLE" you mean the keyboard and mouse are not in use. You could use GetLastInputInfo to determine the status in your scripts:

int _tmain(int argc, _TCHAR* argv[])
{  DWORD previous = 0;  
while(true)  {    LASTINPUTINFO info;    
info.cbSize = sizeof(info);
DWORD idleSeconds = (GetTickCount() - info.dwTime)/1000;
if (idleSeconds < previous)     {      printf("Idle time: %i\n",previous);
previous = idleSeconds;


and then run any of the other tasks you have planned.

I believe shutdown.exe refers to "idle" when the mouse and keyboard have been inactive for x amount of time....I'm not sure if it uses the same setting that Win32 uses for screensavers... (Please see attached image). It also has a setting to "wake up the computer" that might be useful to you...

You have highlighted several times the word "IDLE" in your responses and I am guessing that we are probably talking about different definitions of idle and thus the confusion in our conversations....

PS: Correction of above ...."it uses the same setting that Win32 uses for screensavers......."
I meant  " uses the same setting for Win32 Screensavers...."
canuc0Author Commented:
As we use group policy heavily, I'm awarding most points to options that use it. I will use a solution that combines many of the suggestions above and elsewhere in EE. Thanks all for your input,
S ConnellyTechnical WriterCommented:
Very interesting thread and something I am dealing with now as well.
 I am surprised that no one mentioned an application that has been receiving a lot of press lately... called Faronics Power Save. 
For a fellow school admin... this app is perfect and very popular among schools (as well as Faronics' Deep Freeze app). I love these people, their support team is amazing at solving virtually any problem!  
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.