Reason: File and command have the same name.
I wanted to use the ROBOCOPY command inside the ROBOCOPY file. This is mistake.
The file ultimately calls itself.
Solution 1. Rename the batch file.
One solution is to rename the batch file other than the command (s) in the file.
Solution 2: use a more explicit command call
Another solution might be to use ROBOCOPY.exe or explicitly specify the full path to exe, for example C: ... \ robocopy.exe. This will prevent “confusion” when invoking a command and invoking the command file itself.
1 x 2 solution
The best solution (thanks Mofi again) is to combine 1 x 2 together. Use a unique batch file name and specify the full path to the command (exe) inside the batch file.
Useful related commands: To determine the full path to the command (exe), see the WHERE command (for example, where Robocopy.exe should be somewhere in the Windows folder.), System variables (for example, SS64 ), or the SET command.
The full version in my case will be launched, for example, BackupRobocopyFiles.cmd with a line:
%SystemRoot%\System32\robocopy.exe "RoboCopy_Files" "RoboCopy_Files_Testing" /MIR /R:2
Note. This will only work if the cmd file is in the root folder F: \ RoboCopy. If I would like to run cmd from another folder (or sheduler), I would indicate the full path to the SOURCE_FOLDER and DESTINATION_FOLDER parameters of the ROBOCOPY command.
Contribution
The answer was found based on the comments: "MC ND", "eryksun". Mofi noted that the original Q did not help. Thanks to everyone.
source share