title: Handling errors in VBScript during execution
body: <p>Looking for a little help with working on error handling in VBscript.</p>
  
  <p>What I am trying to do is tell the script that if an error occurs during one of the commands that it should re run the script. Basically I am just zipping some files and copying them over to a shared drive, then deleting the original copies once the copy is complete. Now if an error occurs in the zip or copy process I don't want the rest of the script running and having it delete the files. So I just need the script to start over.</p>
  
  <p>At the moment all I have it doing is printing out an echo that says "An error has occurred re-run script" but this is going to be done as a scheduled task so I really need it to be automated. I am just not sure how the syntax would work for this or if it is even possible.</p>
  
  <p>I have seen "On Error Resume Next" but not sure how that plays into how I should be writing this. I don't think I Should be using it because I do not want the script to continue if an error occurs I just want it to start from the beginning again. </p>
  
  <p>This is what it looks like at the moment:</p>
  
  <pre><code>Command2 = "Robocopy.exe " &amp; sLocalDestinationPath &amp; " " &amp; sFinalDestinationPath 
  
          RetVal = Shell.Run(Command2,0,true)
  
  
          If err.Number &lt;&gt; 0 Then
          'WScript.Echo "An error has occured copying the files, re-run Script."
          End If
  </code></pre>
  
  <p>If I am going at this problem the wrong way and there is something more efficient I should be doing I would appreciate the help greatly. I am new to VBscript and I am still getting used to it. </p>