Solved

GPO Machine Startup CMD script times out

Posted on 2011-03-22
16
1,117 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:sysadmin-inq
  • 7
  • 6
  • 2
  • +1
16 Comments
 
LVL 7

Expert Comment

by:eugene20022002
Comment Utility
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?
0
 
LVL 43

Expert Comment

by:Steve Knight
Comment Utility
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
 

Author Comment

by:sysadmin-inq
Comment Utility
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
0
 
LVL 43

Expert Comment

by:Steve Knight
Comment Utility
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
 

Author Comment

by:sysadmin-inq
Comment Utility
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.
0
 
LVL 43

Expert Comment

by:Steve Knight
Comment Utility
Try using START then... if the program is just running the exe and staying resident then it is likely closing it by the timeout like you say, i.e.

start c:\dshutdown.cmd

Steve

0
 
LVL 7

Expert Comment

by:eugene20022002
Comment Utility
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?
0
 
LVL 43

Expert Comment

by:Steve Knight
Comment Utility
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:

xcopy \\server\dshutdown\*.* \ C:\ /C /H /R /Y /D
START "C:\DShutdown.exe" /SAVEONEXIT /INACTIVEUSER "for 2 hour" /IP:LocalHost /Shutdown /Force /HIDDEN

Or if you have to map the drive:

net use x: //server/dshutdown
xcopy X:\*.* \ C:\ /C /H /R /Y /D
net use x: /delete
START "C:\DShutdown.exe" /SAVEONEXIT /INACTIVEUSER "for 2 hour" /IP:LocalHost /Shutdown /Force /HIDDEN

Steve
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:sysadmin-inq
Comment Utility
Dragon-it I have added the /D switch per your great suggestion.

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.
0
 
LVL 43

Expert Comment

by:Steve Knight
Comment Utility
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.

set log="c:\logfile.txt"
echo Starting at %date% %time% > %log%
xcopy \\server\dshutdown\*.* \ C:\ /C /H /R /Y /D >>%LOG%
echo Copy completed [%errorlevel%] at %date% %time% >> %log%

START "C:\DShutdown.exe" /SAVEONEXIT /INACTIVEUSER "for 2 hour" /IP:LocalHost /Shutdown /Force /HIDDEN
echo Shutdown EXE completed [%errorlevel%] at %date% %time% >> %log%
echo Ending at %date% %time% >> %log%

0
 
LVL 21

Expert Comment

by:AmazingTech
Comment Utility
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
 

Assisted Solution

by:sysadmin-inq
sysadmin-inq earned 0 total points
Comment Utility
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.

Thank you,
Kirt
0
 
LVL 43

Expert Comment

by:Steve Knight
Comment Utility
Ouch.  Good point!

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.

Steve
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 500 total points
Comment Utility
If you are still using XP then it seems someone has written a tool for enabling hibernation if so through GPO, though I haven't tried it yet...

http://www.energystar.gov/index.cfm?c=power_mgt.pr_power_mgt_ez_gpo
0
 

Author Comment

by:sysadmin-inq
Comment Utility
I will use the dshutdown as a log in script in combination with EZ GPO.

Thanks for the help.
0
 

Author Closing Comment

by:sysadmin-inq
Comment Utility
Answer was a work around, original goal is impossible via GPO.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Recently, I had the need to build a standalone system to run a point-of-sale system. I’m running this on a low-voltage Atom processor, so I wanted a light-weight operating system, but still needed Windows. I chose to use Microsoft Windows Server 200…
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now