Setting a robocopy log file to a variable

1.4k views Asked by At

Robocopy is stalling when reading options /Z /MIR and LOG+ from a variable.

ROBOCOPY %BACKUP_FAVS% %PATH_FAVS% %R_OPT%

Where R_OPT= /Z /MIR /LOG+:%RLOG_Restore% and is set by:

IF %ACTION%==Restore SET R_OPT=/Z /MIR /LOG+:%RLOG_Restore%

Where RLOG_Restore is set by:

SET RLOG_Restore=%BACKUP_FOLDER%\Robocopy_Log_Restore.txt

When the code executes, its stops at the robocopy line and does not continue on to the code after the robocopy line. The robocopy line returns:

Log File : H:\VDI_Backup\Robocopy_Log_Restore.txt

An Echo of the Robocopy results in:

ROBOCOPY  H:\VDI_Backup\Favorites  C:\user\Favorites /Z /MIR /LOG+:H:\VDI_Backup\Robocopy_Log_Restore.txt

I tried enclosing /Z /MIR /LOG+:%RLOG_Restore% in quotes resulting in invalid parameters error. Where is this going wrong?

1

There are 1 answers

0
mechengr02 On

The problem is access denied to the destination folder.
Nothing wrong with robocopy code.