Logoff script is not completing on computers in remote locations
Hi folks, We're running a logoff script on our Win7 Enterprise SP1 machines that invokes three robocopy statements which copy various local directories to our Netapp as a backup. The logoff script is called through GP at 'User Configuration|Policies|Windows Settings|Scripts (Logon/Logoff)'. If the machine is in the corporate office, there is no trouble, the script completes, and all files are copied. If the machine is located at our branch office (connected across the WAN via an IPSEC tunnel), or by Directaccess, the third robocopy statement will not complete, and the logoff script just exits as the user is logged off. The robocopy log is truncated in the middle of the copy. This script can be run interactively and it will complete without difficulty. It would seem that the copy is taking too long to complete? In researching this, I found that the default time allowed for a logon/logoff/startup/shutdown script to complete is 10 minutes, and that this can be changed through GP at 'Computer Configuration|Policies|Administrative Templates|System|Scripts|Maximum wait time for group policy scripts'. The trouble is that even in remote locations, the script fails way before that default 10 minute timeout. In fact, the script runs slightly less than a minute before the logoff occurs. I tried setting the max wait time to 0 (infinite time), but that did not help. I've also tried breaking the three robocopy commands out into separate batch files and invoking each with a 'call' statement, and adding 'start /wait' in front of each command, but neither of those worked either. Does anyone have a clue why the logoff script is exiting so quickly? Thanks for any help, ianc
April 4th, 2012 5:36pm

It seems it is either unreliable procedure or other GP settings override the script execution. 1. Try to model GPO if there is any problem 2. First to come when modifying scipt is shutdown -a at the beginning of script and shutdown -s -f -t 0 at he end (just an idea). 3. Another approach that I am using is waking up computer(s) after working hours (in BIOS), executing script and scheduled shutdown. Regards Milos
Free Windows Admin Tool Kit Click here and download it now
April 5th, 2012 4:22am

Do your robocopy statements log to a file? It may be worth while to tweak your batch scripts a bit to generate a log. @echo off echo. & echo Backing up Data Set 1 - Please Wait ... @echo %date% %time% - Starting Robocopy 1 of 3 >> C:\Logoff.log robocopy /s /w /i /t /c /h /e /s source1 destination1 /log+:C:\Logoff.log @echo %date% %time% - Finished Robocopy 1 of 3 >> C:\Logoff.log echo. & echo Backing up Data Set 2 - Please Wait ... @echo %date% %time% - Starting Robocopy 2 of 3 >> C:\Logoff.log robocopy /s /w /i /t /c /h /e /s source2 destination2 /log+:C:\Logoff.log @echo %date% %time% - Finished Robocopy 2 of 3 >> C:\Logoff.log echo. & echo Backing up Data Set 3- Please Wait ... @echo %date% %time% - Starting Robocopy 3 of 3 >> C:\Logoff.log robocopy /s /w /i /t /c /h /e /s source3 destination3 /log+:C:\Logoff.log @echo %date% %time% - Finished Robocopy 3 of 3 >> C:\Logoff.log echo. & echo Finished Backing Up Data! @echo %date% %time% - Exiting Script >> C:\Logoff.log exit /b Depending on the results of that, you may want to consider maybe creating a different script to perform some tests to validate network connectivity. The example below is a bit over the top but we ended updoing something similar to what's below for testing remote connections, especially when users had intermittent connectivity problems. (Hence the goto top) @echo off set ExternalHosts=www.yahoo.com www.google.com www.msn.com www.aporter.com %gateway% set InternalHosts=someserverhostname1 some.server.IP.Address1 someserverhostname2 some.server.IP.Address2 set logfile=C:\ExternalNetworkTest-PathPing.txt if exist "C:\windows\system32\pathping.exe" ( set ptcmd=pathping -n %%i set trace=0 ) else ( echo %date% %time% Pathping does not exist on this machine - relying on ping and trace >> %logfile% set ptcmd=ping -n 10 %%i set trace=1 ) echo ********************************************* >> %logfile% date /t >> %logfile% echo ********************************************* >> %logfile% echo. >> %logfile% :TOP for %%i in (%ExternalHosts%) do ( CALL :CURDT %logfile% echo ********************************************* >> %logfile% %ptcmd% >> %logfile% if /i %trace%==1 CALL: TRACE %%i CALL :GETIPINFO %logfile% ) for %%i in (%InternalHosts%) do ( CALL :CURDT %logfile% echo ********************************************* >> %logfile% %ptcmd% >> %logfile% if /i %trace%==1 CALL: TRACE %%i CALL :GETIPINFO %logfile% ) rem CALL :GETIPINFO %logfile% echo. >> %logfile% rem you could have it loop but for this test rem that is not necessary for you rem GOTO TOP rem goto end :CURDT set hh= set hhmmss= set hh=%time:~0,2% if "%time:~0,1%"==" " set hh=0%hh:~1,1% set hhmmss=%hh%:%time:~3,2%:%time:~6,2% echo %hhmmss% >> %1 GOTO :EOF :TRACE set tracecmd=tracert -d %1 CALL :CURDT %logfile% echo ********************************************* >> %logfile% %tracecmd% >> %logfile% GOTO :EOF :GETIPINFO ipconfig /allcompartments /all >> %1 rem Get IP Adddress for /f "usebackq tokens=15" %%a in (`ipconfig ^| find /i "IP Address"`) do set ip=%%a rem echo %date% %time% IP Address is %ip% >> %logfile% rem echo %date% %time% IP Address is %ip% >> %1 rem Get Gateway for /F "usebackq tokens=13" %%i in (`ipconfig ^| find /i "gateway"`) do set gateway=%%i rem echo %date% %time% Gateway is %gateway% >> %logfile% rem echo %date% %time% Gateway is %gateway% >> %1 GOTO :EOF :END echo %date% %time% exiting script >> %logfile% exit /b
April 5th, 2012 4:06pm

Hi guys, thanks for your responses. I have tried a GP results on a remote user and the user\computer is getting the apropriate policies, including the slow link detection being set to 0 in the user policy to remove that possibility. I am in fact logging the results of the robocopy jobs, and as mentioned in the first post, when the third robocopy job runs, it begins its log, but then the log just truncates in the middle when the job is killed as the logoff occurs. The problem is not associated with that particular job either: if I run that one first instead, it still times out on the last one. The problem is also not related to network connectivity. I can ping the remote user's machine throughout the entire logoff process with no dropped responses. It seems to be related to time only, as in all cases, the script just stops running after ~55 sec. Thanks for any further suggestions! ianc
Free Windows Admin Tool Kit Click here and download it now
April 5th, 2012 5:03pm

OK, I have fixed this, and I'm afraid the problem was due to my own idiocy. The solution was in fact the GP setting 'Computer Configuration|Policies|Administrative Templates|System|Scripts|Maximum wait time for group policy scripts', and this needed to be set to 0 (infinite). The trouble was that I had made this setting in a policy object which was applied to an OU containing only users; hence it was never applied. After applying it to the OU which contained the user's workstation, all worked as advertised. Sorry for wasting your time, but hopefully this helps someone else in future, ianc
April 5th, 2012 6:06pm

Thanks for updating the post! Congrats on finding it.
Free Windows Admin Tool Kit Click here and download it now
April 6th, 2012 1:54pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics