Windows 7 shutdown through Group Policy Preferences
by, 6th December 2012 at 06:20 PM (109896 Views)
Shutting down Windows 7 has been a bit of a bug bear, with some PCs refusing to shut down, or settings not quite working the way I wanted them to. In an ideal world, I wanted a situation where computers would attempt to shutdown at 3.15, and only stay on if someone was using it. The PC would then wait until 10 minutes after it had gone Idle, then shut itself down. In reality, the first part usually worked fine, the second part, not so much.
My preferred method of shutting down is though Group Policy Preferences - Scheduled tasks. I set a scheduled task to run the inbuilt shutdown command within Windows 7 to run a 15.15, with various settings to wait for idle for 15 minutes, and only shut down if the PC had been idle for 10 minutes. It was this second part that didn't seem to kick into gear, no matter how much I tinkered with the settings. It appears, from my experience, that if the inital command can't run, the scheduled task is then set as 'Queued' and then refuse to run, even after the set idle time had elapsed. I had set this task to run again at 16.15 and again at 20.00. However, by this point the scheduled task had become a touch unwieldly in size, and was having a negative impact on boot up times. Also, if PCs missed the 16.15 shutdown time, PCs were left on for a long time before finally shutting themselves off. A better way was needed.
My settings are now as follows:
Boot up Group Policy Management
Create new GPO
Computer Configuration - Preferences - Control Panel Settings - Scheduled tasks - Scheduled task (Windows Vista)
Name the task
I would strongly recommend using a domain admin as the user to run the task as, but I leave it up to your own security procedures as to whether you do this or not.
Triggers - New... Set for every weekday at 15:15 then Repeat task every 1 hour for the duration of 12 hours.
Actions - New - Start a program "C:\Windows\System32\shutdown.exe" Add arguments /s /t 90 /d p:04:01 (Arguments are shutdown, after 90 seconds, with a reason - I find the later prevents 'This computer shutdown unexpectedly' errors for students first thing in the morning').
Conditions - Start the task only if idle for 10 minutes - wait for idle 15 minutes - stop if computer ceases to be idle and restart if the idle state resumes (I keep the wait for idle time and restart if idle state resumes more out of hope than any knowledge that they will actually work) - Wake the computer to run this task (not really useful as I turned off sleep mode as I found Windows 7 wasn't always 100% reliable in waking up again).
Settings - Can leave blank, I've ticked if the running task does not end when requested, force it to stop as it seemed like a good idea.
Common - Remove this item when it is no longer applied - I find this very helpful should I want to change the settings later, but again YMMV.
Once all this is set up, click on OK and apply to relevent OUs.
What this will do is run the shutdown script at 15:15 and then quarter past the hour every hour until 04:15. If the machine is in use, then it will wait until the next time to try and shutdown again. I believe it will also pick up on machines that have been turned back on after being shutdown, but I haven't 100% tested this.
So there we have it, I hope someone finds this useful!
Total Trackbacks 0