• Robocopy command runs from command prompt, not from .cmd batch file

    Home » Forums » AskWoody support » Windows » Windows 10 » Questions: Win10 » Robocopy command runs from command prompt, not from .cmd batch file

    Author
    Topic
    #508396

    The routine is to copy data from the local drive (C:) to a connected network server (F:)

    This is the command:
    robocopy “C:Eudora userdata” “F:privateartEudora Userdata Backup” /MIR /V /NP /R:10 /W:10
    pause

    When I run the command directly from a command prompt, it runs fine.
    When I run it (as administrator) from the .cmd batch file, I get the following error:

    The system cannot find the path specified. Apparently it’s the network path that’s not resolving. Why would this be true from a .cmd batch file and not when run from the command prompt?

    Thanks for any thoughts…

    Viewing 5 reply threads
    Author
    Replies
    • #1593953

      Art, do you do any CD command in the prompt window before running, or do you navigate to the folder and run the manual CMD prompt from there?
      “C:Eudora userdata” is probably not on your default Windows path, so the batch file doesn’t know where to start.

      If that’s the case, add…
      CD “C:Eudora userdata”
      …as the first line in the batch file.

      Btw I don’t use CMD much this century, does it handle longer than 8-character folder and file names these days? If not, “C:Eudora userdata” might need to be “C:Eudora~1

      PS your image doesn’t show for me, just a little “x”.

      Lugh.
      ~
      Alienware Aurora R6; Win10 Home x64 1803; Office 365 x32
      i7-7700; GeForce GTX 1060; 16GB DDR4 2400; 1TB SSD, 256GB SSD, 4TB HD

    • #1594003

      A suggestion: do check if your administrator account (under which you run the .cmd file as opposed to the user account used for the command prompt) has the network server location mapped to the F: drive. Different accounts may well have different drive mappings!

    • #1594016

      Drive mappings are generally per user, so you as an admin will not have the drive mapped.
      Try using the full path, e.g. “\servershareprivateartEudora Userdata Backup”

      cheers, Paul

    • #1594037

      Art,

      I ran across this when writing a PowerShell script to provide drive information.

      If drives were mapped using standard user privileges, even from an administrator account, they will not show up if a script is run as Administrator!

      Take Paul’s advice and It should work no matter how you run it.

      HTH :cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

    • #1594147

      How?

      cheers, Paul

    • #1594150

      I wish I knew! Yesterday, I finally had a chance to try out the suggestions in this thread and the problem had vanished. I tried running the .cmd file again just to confirm the error and it ran without a hitch (no changes in drive mappings, admin status, etc.). All I can think is that there was some kind of network gremlin screwing-up the path mapping that, in the interim, has moved on. Anyway, I appreciate the good and thoughtful suggestions and observations here. I’m new to windowssecrets.com and I’m glad to know about the site!
      Cheers,
      Art

    Viewing 5 reply threads
    Reply To: Robocopy command runs from command prompt, not from .cmd batch file

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: