'robocopy' is not recognized as an internal or external command, operable program or batch file.

CharlieLor 551 Reputation points

I keep getting this error whenever I run a .cmd file with robocopy. I have already tried suggestions from this thread and it's still not working. Any help is much appreciated.

A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
4,946 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Xiaowei He 9,876 Reputation points


    Please check if the robocopy.exe exists and is well in Windows, please find the robocoy.exe in the file explorer.

    And then, please ensure you direct to the right file location that stores the robocopy.exe.

    Thanks for your time!
    Best Regards,


    If the Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

  2. MotoX80 32,526 Reputation points

    There are 3 possible issues.

    1. The file does not exist.
    2. C:\windows\system32 is not in the system path variable.
    3. Something within the .cmd file is changing the path variable

    Does C:\windows\system32\robocopy.exe exist?

    Does your cmd file execute C:\windows\system32\robocopy.exe or does it just call robocopy? If the latter, change the statement to include the full path to the file.

    Does the error only occur when you run that cmd file? If you just open a command prompt window and type in robocopy, does the program execute? Does anything in the cmd file reference %path%?

    If you open a command prompt window and run this command, what does it show?

    where robocopy


    0 comments No comments

  3. CharlieLor 551 Reputation points

    Noticed in the screen shot below, if I use the robocopy at the prompt it works. There is no error. However, when I run the .cmd file that contains the exact robocopy line, it errors out.


  4. CharlieLor 551 Reputation points

    Okay, I got it working. It seems that I can't use .cmd as the file extension. I have to use .bat as the extension.