OT Trying and failing to get robocopy to work Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

OT Trying and failing to get robocopy to work

19 Jun 2021, 04:38

I've tried runwait robocopy and runwait %COMSPEC% /c Robocopy but neither works. I tried using robocopy directly from cmd but also got an error:
The filename, directory name, or volume label syntax is incorrect.
I can use the same paths for filecopy or filemove and have no problem but I need to use robocopy because I want to move protected macrium image files. At cmd prompt I tried robocopy /? and it seems Ok but I can't get it to actually copy anything. Can anyone suggest a way to fix it or approach to test it? Thanks.
User avatar
mikeyww
Posts: 26889
Joined: 09 Sep 2014, 18:38

Re: OT Trying and failing to get robocopy to work  Topic is solved

19 Jun 2021, 06:18

You did not specify your file paths in your post, and that appears to be the problem, according to the error message. The following test worked for me. If you do not have permission to the directory, it would probably fail. You could try running as admin, or removing the trailing backslash from your file paths. Since Robocopy generates an ErrorLevel, it may also be informative.

Code: Select all

source = e:\data\temp2\t\t2
target = e:\data\temp2\t\t3
err := {16: "***FATAL ERROR***"         , 15: "OKCOPY + FAIL + MISMATCHES + XTRA"
      , 14: "FAIL + MISMATCHES + XTRA"  , 13: "OKCOPY + FAIL + MISMATCHES"
      , 12: "FAIL + MISMATCHES"         , 11: "OKCOPY + FAIL + XTRA"             , 10: "FAIL + XTRA"
      ,  9: "OKCOPY + FAIL"             ,  8: "FAIL"
      ,  7: "OKCOPY + MISMATCHES + XTRA",  6: "MISMATCHES + XTRA"                ,  5: "OKCOPY + MISMATCHES"
      ,  4: "MISMATCHES"                ,  3: "OKCOPY + XTRA"                    ,  2: "XTRA"
      ,  1: "OKCOPY"                    ,  0: "No Change"}
RunWait, Robocopy "%source%" "%target%",, Hide
MsgBox, 64, ErrorLevel = %ErrorLevel%, % err[ErrorLevel]
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Re: OT Trying and failing to get robocopy to work

19 Jun 2021, 07:29

Thanks, Mikey, for such a thorough reply. I tried the following:

Code: Select all

source := "X:\Images W10"
target := "m:\test"

Runwait, Robocopy, "%source%" "%target%" /xf *.mrimg
MsgBox, 64, ErrorLevel, %ErrorLevel%, % err[ErrorLevel]
And got Errorcode 16. However if I try this cmd code it worked (copying all the txt files and excluding the mrimg files):

Code: Select all

robocopy "x:\images w10" "m:\test" /xf *.mrimg
Error code 16 is fatal error. Seems I can't get robocopy to work with ahk.
User avatar
mikeyww
Posts: 26889
Joined: 09 Sep 2014, 18:38

Re: OT Trying and failing to get robocopy to work

19 Jun 2021, 07:47

Use my format: no comma after the command. Why? AHK uses commas to identify its own parameters. Your command-line format also has no comma!
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Re: OT Trying and failing to get robocopy to work

19 Jun 2021, 09:31

Thanks , Mikey, I didn't notice the comma and it makes all the difference!. With that change I got error code 1, which means it worked.
User avatar
boiler
Posts: 16931
Joined: 21 Dec 2014, 02:44

Re: OT Trying and failing to get robocopy to work

19 Jun 2021, 13:57

Without the comma, it all goes in the first parameter of RunWait (Target) which means you’re running robocopy and passing those arguments to it as you would when typing them into a CMD window, With the comma, you’re putting what follows it in the second parameter of RunWait, which is the working directory.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 322 guests