Search code examples
windowsbatch-filecmdxcopygroup-policy

Logon / Logoff Scripts with xcopy not Working


I'm setting up a pair of logon and logoff scripts that will download and upload the users Outlook signatures automatically to and from their home directory (Z:\ drive).I'm using the scripts below, which work fine when run manually, but do not seem to be running at all (or at least not working) when set up as logon and logoff scripts with group policy. I have verified with gpresult that the scripts are indeed applied. 

Logon Script (to download signatures):

@echo off
set LOGFILE=Z:\batch.log
call :LOG >> %LOGFILE%
exit /B

:LOG
if exist "Z:\Signatures\" (
    xcopy /e /Y /D Z:\Signatures %appdata%\Microsoft\Signatures
    )

Logoff Script (to upload signatures):

@echo off
set LOGFILE=Z:\batch.log
call :LOG >> %LOGFILE%
exit /B

:LOG
if not exist "Z:\Signatures\" (
    mkdir Z:\Signatures
    attrib +h Z:\Signatures /s /d
    )

xcopy /e /Y /D %appdata%\Microsoft\Signatures Z:\Signatures

Does anyone have an idea why this wouldn't be working?


Solution

  • Fixed by using %homeshare% instead of the mapped Z:\ drive