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

CharlieLor 551 Reputation points
2021-02-26T19:58:01.227+00:00

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.

Windows
Windows
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,802 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Xiaowei He 9,871 Reputation points
    2021-03-01T07:18:34.907+00:00

    Hi,

    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,
    Anne

    -----------------------------

    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,081 Reputation points
    2021-02-27T03:15:04.443+00:00

    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
    2021-03-01T14:07:30.917+00:00

    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.

    73028-image.png


  4. CharlieLor 551 Reputation points
    2021-03-01T14:14:16.667+00:00

    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.