Jump to content

Robocopy Exit Codes in Autoit


Recommended Posts

Hi,

I have deployment system and at one part there is copying files to the system. Since the whole deployment system depends on copy step, it is quite important. 

Eventhough this exact code was working without any problem, it started not to work i need an other eye to check. I will be really glad if you help me with this.

I started to get the return code as 0 all the time no matter what problem gets in robocopy. I need to get the return code of robocopy so i can see the problems if there is. 

What would cause this piece of code not to work eventhough there were no changes at the code ?

- I need to use RunWait since the next deployment should not start until the first one finishes

For $j=1 to $RetryVal
    ConsoleWrite("Procedure is starting... Try count: "& $j & @CRLF)

    Local $returncode = RunWait("robocopy """&$sourceDirectoy&""" """&$destinationDirectory &""" /E /R:3 /W:1 /NP /XX")

    If (16<$returncode OR $returncode<8) Then  ExitLoop
    Sleep(3000)
Next

If (17>$returncode And $returncode>7) Then
    ConsoleWrite("There was a problem ")
    $ErrorFlag=1
Else
    ConsoleWrite("Everything was OK ")
EndIf

ConsoleWrite("and here is the return code : "& $returncode & @CRLF)
Link to comment
Share on other sites

did you read that hint:

Bugs
Version XP026 returns a success errorlevel even when it fails.

sounds exactly like your problem

Edited by Edano

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to comment
Share on other sites

Thanks a lot!!!

I dont know who changed the robocopy at the server but this was driving me crazy :) Now I downgraded to 5.1.1.1010. it is working as it is supposed to :)

However I have a question mark about a point.

With the bugged version when i was testing with a batch file it was giving the error as it is supposed to, with downgraded version it is giving the error too.

Only thing is not working between two robocpy version is my autoit script. isnt this weird ? with robocopy bugged version, batch file should return OK as well ?

Here is that batch file

@echo off

robocopy C:\sourceDirectory C:\destionationDirectory /E /R:1 /W:1 /NP /XX

if errorlevel 4 goto error
if errorlevel 3 goto OKCopyAndDel
if errorlevel 2 goto OKDelete
if errorlevel 1 goto OKCopy
if errorlevel 0 goto OKNothing

:OKCopyAndDel
  echo (3) Ok Copy and Delete
  goto end

:OKDelete
  echo (2) OK Delete
  goto end

:OKCopy
  echo (1) OK Copy
  goto end

:OKNothing
  echo (0) Nothing happened
  goto end
:error
  echo ERROR!!!!

:end
echo -----------------------------------------------------------
Link to comment
Share on other sites

:) sorry, but this is above my brain capacity. maybe you should try another robocopy version ? but make sure nobody updates it.

btw. there is nothing in robocopy that autoit couldn't do. make it completely in autoit, if robocopy is so flawed.

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to comment
Share on other sites

Robocopy isn't flawed the earlier version was only for 2003 etc  ie: 5.1.1.1010 but its limited

5.1.2600.26 has the above error and 5.1.10.1027 is the fixed version as far as im aware but it wont work below Vista

http://en.wikipedia.org/wiki/Robocopy

I use Robocopy like this example but i dont do too much with error checking

'?do=embed' frameborder='0' data-embedContent>>

Its never let me down over thousands of backups at work

Edited by Chimaera
Link to comment
Share on other sites

i've also made an autoit backup script with zipping for my work, with timer and automatic deletion after x days ..... at least i know what it does and that gives me a good feeling. never needed the backup tho....

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...