thephoquang
thephoquang

Reputation: 63

Cannot run batch file with xcopy command

The code in batch file is :XCOPY "D:\hosts" "C:\Windows\System32\Drivers\etc" /R /Y. But it doesn't work. cmd run like :enter image description here

How do I fix this?

Upvotes: 0

Views: 819

Answers (1)

paxdiablo
paxdiablo

Reputation: 881083

Based on the output, I'd say you've called your batch file xcopy.cmd or `xcopy.bat.

That means, when it tries to call the actual xcopy executable, it instead calls itself in an infinitely recursive loop.

If that is the case, you have a couple of options:

  1. Rename your batch file to something more sensible, such as copy_hosts.cmd, something that's not likely to clash with a real command; or
  2. Make sure you call xcopy.exe explicitly from your batch file, so it goes and gets the real one.

Upvotes: 1

Related Questions