Root Loop
Root Loop

Reputation: 3162

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?

Upvotes: 5

Views: 11355

Answers (3)

P S
P S

Reputation: 13

Change the name of your .bat file to something else from robocopy.bat.

This happed to me as well earlier.

Upvotes: 0

Bitcoin Murderous Maniac
Bitcoin Murderous Maniac

Reputation: 1478

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.

Upvotes: 18

OK999
OK999

Reputation: 1399

As @MCND and @foxdrive already commented the solutin/the cause is the fact that the file have the same name as the command itself.

Upvotes: 0

Related Questions