GPO Machine Startup CMD script times out

Hello Experts:
I need help implementing a power policy that shuts down the computers for inactivity. As this is not a native feature in Windows Server 2003/ XP I have to use a work around. I have found a program call dshutdown (http://dimio.altervista.org/eng/) which looks like it will work great. I created a Batch file to copy the files from a shares drive to the local computer then run the dshutdown.exe via the command line. Command looks like "C:\DShutdown.exe" /SAVEONEXIT /INACTIVEUSER "for 2 hour" /IP:LocalHost /Shutdown /Force /HIDDEN

After testing in a local environment, I have determined that this script/program works just like I plan. However when I apply the same batch file to a Group Policy the Startup Script times out after 10 minutes and does not launch dshutdown. But it does copy the files from the server, so I know the script runs. Any clues on why it would work as expected from editing the local gpedit.msc computer startup script, but times out from a Server side GPO?

On a side note I can get the script working via a user logon script, but this is not an option as it gives the user the ability to kill the program. Also if the user logs off it close the program and the computer will remain on.
Thank for your help in advance,
SysAdmin

while testing the GPO on yourself , put a pause command at the end of your batch script and let it echo so that you can see any errors it displays. Should help you troubleshoot it better when you have an idea of what is wrong.
BTW do you get any errors?

Hmm, does the exe get started at all but then gets terminated at the 10 mins, or never run?

I haven't tried runing a background program from GPO startup script as normally have other methods available but perhaps if you start it using START? Likewise like the other person said if you run the script visible from the GP settings if it isn't already and remove the /hidden on dshutdown.exe?

Other way would perhaps be to get it to add a "Run" key registry entry I suppose using REG.EXE or a .REG file so that it runs this exe or a batch file to start it independent of needing the GP startup script?

Listening out of interest anyway as one company I assist is mooting such as policy too...

Steve

0

sysadmin-inqAuthor Commented: 2011-03-23

eugene20022002 and dragon-it, Thanks for the replies. I found a way to get this script to work under the local system account. With a few bugs, maybe you’ll know how to fix.
My original script followed this format:
net use x: //server/dshutdown
xcopy x: \ C:\ /C /H /R /Y
net use x: /delete
C:\Dshutdown.cmd (this is where the script was timing out)
Modified Script looks like:
net use x: //server/dshutdown
xcopy x: \ C:\ /C /H /R /Y
net use x: /delete
net use p: //server/dshutdownscript
p:\Dshutdown.cmd
net use p: /delete
When I apply the modified script to a Domain Computer the first time the script runs, it times out again. But upon the next restart the Policy works as expected. I have ran the cmd.exe in interactive mode and can not find the reason why it behaves this way. Bug one script times out the first time it runs, but works correctly upon additional restarts. Why not work correctly from the get go?
Bug 2 is that net use p: /delete never runs. This is not a big issue as the users are really restricted and are unable to open windows explorer and unable to see the map drives. But admin can and see the P: as a mapped drive.
Thanks,
Kirt

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Bug 2 - add call to run the cmd then return to calling script.... shouldnt it be c: though? Will look back later sorry, kids to sort out etc.

Steve

0

sysadmin-inqAuthor Commented: 2011-03-23

Hi Steve, adding call to cmd did not have any affect. If I call it from c: the program does not launch due to the script timing out. That's why I use net use P: to call the local script to launch the program. I know it seems like an extra step, but it is the only way I could figure out how to launch the program via the GPO.

for the net use p: /delete to work you would want to put that at the start of the script so that it runs before the rest of it.
Does the script show the same symptoms under ALL OS? or just 1 particular OS?

Personally I'd add /D to the xcopy too so it only copied if the file had changed and do away with the mapped drive.... and no particular reason for not running the EXE directly rather than another batch file , also you had batch file the same name which is OK.... but why not just:

However, no matter if I use start/call or just run the cmd in the batch file, I get the same results. After testing and ripping out my hair. I have found that all the above scripts work if the idle time is 10 minutes or less. Anything above ten minutes the program just closes and an error is written in the event viewer that the GPO was not applied due to a time out. Which makes no sense to me as the dshutdown program is being launch from the local computer and script should have already been closed.

Hmm, if you run something without START the script will still be running in the background and you will somewhere in group policy have it set as a maximum script execution time of 10 mins.

I'm not quite sure what is going on here. When the computer logs on are you seeing this script runing visible for starters? If not probably worth turning that on for now. Then you can see if the cmd.exe window is still sitting there for instance.

Is it worth perhaps getting the exe put into the HKLM "Run" key using a REG.EXE command or .REG file, i.e. in : HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run ?

try some logging to see what is going if you can't set it to run visible, i.e.

It's possible your problem is with DShutdown and GPO Machine Startup script because a user is not logged in and dshutdown maybe trying to access the currently logged on user.

0

sysadmin-inqAuthor Commented: 2011-03-25

Hi:

I just realized the launching dshutdown from the system account has a major flaw that put an end to this project. If the system account starts dshutdown with the inactivity switch the pc will shutdown after the inactive time even if a user is or has been using the PC. For example the script launches the dshutdown.exe /INACTIVEUSER "for 2 hour" under the system account at 7:30am no matter if the computer is in use or not the system will shutdown at 9:30am. This is due to the inactivity of the System User Account.

I could assign it as a login script, so if User1 logs in dshutdown is started using his credentials. But as stated in my original post this gives the user the ability to kill the program via Task Manager and kills the program when the user logs off. Which is better than having the computer only stay on for 2 hours at a time, but still defeats the purpose of this GPO.

Any suggestions on programs or methods to accomplish the goal of have the 100+ computers in the office shutdown if not in use for 90 minutes or greater would be greatly appreciated.

What about hibernation? Could you not enable the computers to go into hibernation (i.e. effectively off power wise) when idle? Also saves the issue of what to do with the document the user decided to leave open and unsaved etc. as it will still be there when they switch back on.

Featured Post

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.