Link to home
Start Free TrialLog in
Avatar of canuc0
canuc0Flag for Australia

asked on

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.
Avatar of jwenting
jwenting
Flag of Netherlands image

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.
Avatar of BALMUKUND KESHAV
Type in expert-exchange search-- All zones, shutting down remote computer and you will find very useful links like this :

https://www.experts-exchange.com/questions/21633189/Shut-down-a-machine-remotely.html?sfQueryTermInfo=1+comput+down+remot+shut

Bm Keshav
Avatar of ScumPuppy
ScumPuppy

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
c:
cd\
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

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:
http://howtobuycomputer.net/computer_sleep.html

hope this help.

SOLUTION
Avatar of BitsBytesandMore
BitsBytesandMore
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
cls
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 rules....one 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 data....you 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 :http://www.surlyjake.com/windows/remotely-change-power-options-in-xp/
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.........
Avatar of canuc0

ASKER

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.
canuc0,

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.....
Avatar of canuc0

ASKER

Bits,
perhaps I missed something here - how can you use shutdown command with idle time?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of canuc0

ASKER

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:
http://www.aquariussoft.com/pc-shutdown/default.asp
Avatar of canuc0

ASKER

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:
http://support.microsoft.com/kb/314999
and then use a scheduled script later at night from a server to shut all computers down in an OU:
https://www.experts-exchange.com/questions/24298702/Reboot-Computers-In-Multiple-OU's-VBscript.html

Any thoughts on this? 'Round about way, but might work...cannot believe there isn't a group policy option to do all this!
canuc0
canuc.....you run the shutdown task scheduled on each individual  CLIENT...NOT THE SERVER....
idle.jpg
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 ..you 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" .....
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
pepepaco,
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 then....it still causes issues which eventually will force you to reboot and in a students case .....how 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.
http://en.wikipedia.org/wiki/Wake-on-LAN
"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."
Avatar of canuc0

ASKER

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,
canuc0
Hey canuco,
Your plans sound great....when I mentioned "to walk to each pc"....it 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 yes...you 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...
Avatar of canuc0

ASKER

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 (wshell.run) 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"....lol

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 time....to 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 scripts....you 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.....
Avatar of canuc0

ASKER

Bits,

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!

canuc0
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
PS: Correction of above ...."it uses the same setting that Win32 uses for screensavers......."
I meant  "...it uses the same setting for Win32 Screensavers...."
Avatar of canuc0

ASKER

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,
canuc0
 
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.  
http://www.faronics.com/html/PowerSave.asp 
   
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!