Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Robocopy become a endless loop

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?

like image 427
Root Loop Avatar asked Dec 08 '22 08:12

Root Loop


1 Answers

Robocopy Endless Batch Script Loop Fix

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.

like image 168
Bitcoin Murderous Maniac Avatar answered Dec 11 '22 11:12

Bitcoin Murderous Maniac