I have a robocopy batch file in C:\batch. Here is the batch file:
set LOG="C:\Log\robolog.txt"
set START1="C:\WORK"
set END1="\\fs-02\Work"
Robocopy %START1% %END1% /MIR /PURGE /SEC /SECFIX /R:1 /W:5 /V /ETA /LOG:%LOG%
My question is if i open cmd from the location (c:\batch) that contains this batch file and run it from there, it just runs it over and over again and never ends....and i can not even terminate the cmd.... Ctrl+C
will only speed up the loop.....
but if cmd start location is somewhere else, the batch file runs and finishes well.
Any idea why I CAN NOT run this robocopy batch file directly from the location that contains it?
The Cause
If you have a Batch script with the name Robocopy.cmd
for example, you will get an endless loop when you execute the script.
Happened to me
I was testing and noticed this but didn't know having the name of the script the same as the command will cause Robocopy to endlessly loop. It worked from command line but looped endlessly from the batch script once it was executed.
The Solution
Don't have your batch script named just Robocopy
and rename it to something different e.g. Robocopyzzz
, script123
, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With