Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

GPO Machine Startup CMD script times out

Posted on 2011-03-22
16
Medium Priority
?
1,149 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
ID: 35196140
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
ID: 35196284
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
ID: 35201319
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
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LVL 43

Expert Comment

by:Steve Knight
ID: 35201455
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
ID: 35203092
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
ID: 35203186
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
ID: 35204763
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
ID: 35204790
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
 

Author Comment

by:sysadmin-inq
ID: 35209548
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
ID: 35209669
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
ID: 35216491
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
ID: 35218387
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
ID: 35219019
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 2000 total points
ID: 35219037
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
ID: 35237164
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
ID: 35304410
Answer was a work around, original goal is impossible via GPO.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

772 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