set localdir = "C:\some\directory" SET ErrorMsg = "Could not change working directory to " & localdir WORKINGDIR localdir IFERROR goto failed ;; Do more processing here :done EXIT :failed ;; There was an error, so send custom email message SET mailbody = ErrorMsg & %crlf & %lasterrormsg EMAIL mailbody /subject="RoboFTP Error!" EXIT /exitcode=2000