SyncToy Exit Codes for Batch Scripts RRS feed

  • Question

  • I have a very robust 'dos' batch script that calls SyncToy (V1.4) to sync a folder pair but when SyncToy exits, I'd like to test the exit code to ensure all went well and issue an alarm if needs be.


    SyncToy seems to exit with code '0' if all is OK but there are others, for example an exit code of '5' seem to suggest the sync failed (maybe by a locked file) - I'm therefore guessing that exit codes 2-4 must also exist and have a meaning.


    My code goes along the lines of:....


    @echo off

    set SyncEXE=C:\Program Files\Microsoft\SyncToy\SyncToy.exe
    set SyncPair=DigitalDarkroom


    . [Some other work is done here to make sure a USB drive is attached etc]


    echo Syncing folders - Please wait......
    "%SyncEXE%" -R"%SyncPair%"
    if %ERRORLEVEL% neq 0 goto BadSync

    goto End


    echo An error occured during the file/folder sync - It may not have worked !
    goto End


    It would be nice to test for exit codes other than just '0' to give better feedback as to what may have happen.


    Does anyone have a full set of exit codes?



    Sunday, April 13, 2008 4:03 PM