title: Cmd errorcode output redirection to temporary variable
body: <p>I want to redirect my cmd error code output to a temporary variable so that I can apply an if-else condition on that variable to get a required output. The temporary variable may contain error code '0' or '4' depending upon execution of that cmd command. The code I am using is given below-</p>
  
  <pre><code>"db2cmd -w -c -i db2 restore db %1 from %2 to d: replace existing" &gt; "&lt;.....temp var.....&gt;"
  
  IF NOT ERRORLEVEL 0 goto Label1
  cscript abc.vbs
  exit ERRORLEVEL
  
  :Label1
  cscript pqr.vbs
  exit ERRORLEVEL
  </code></pre>
  
  <p>Can anyone tell how this can be done?</p>