@ECHO OFF
REM Find where My Docs has been redirected to
REM Why are you using double colons for remarks? They are unofficial and break FOR loops
REM needs skip=2 on my Windows 7 machine to produce this: SET KEY=%USERPROFILE%\Documents
FOR /F "skip=2 tokens=2*" %%I in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Personal') DO echo SET KEY=%%J
REM I don't have peIIRClient.exe.config on my machine, so I can't test this bit
REM Copy test file up to redirected store, if they dont exist
REM FOR %%K in ("%USERPROFILE%\My Documents\peIIR.Client.exe.config") DO (
REM IF NOT EXIST "\\Server-file1\fs1\PEfile\peIIR.Client.exe.config %%~nxK" XCOPY "%%K" "%KEY%\"
REM )
REM 'end' is not a legal batch command
REM end
OK I got it to half way work like this:
@ECHO OFF
REM Find where My Docs has been redirected to
FOR /F "skip=2 tokens=2*" %%I in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Personal') DO echo SET KEY=%%J
REM Copy test file up to redirected store, if they dont exist
FOR %%K in ("%USERPROFILE%\Documents\peIIR.Client.exe.config") DO (
IF NOT EXIST "\\Server-file1\fs1\PEfile\peIIR.Client.exe.config %%~nxK" XCOPY "%%K" "%KEY%\"
)
The problem I am encountering is that its copying the file to the C:\ and not to the Documents folder. Any ideas?