Robocopy become a endless loop

半世苍凉 提交于 2020-05-27 05:19:09

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/22989626/robocopy-become-a-endless-loop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!