title: Return Error Message from START /WAIT Command calling DTUTIL
body: <p>All,
  I am using a batch file to automate the deployment of SSIS packages out to MSDB.  I am using a <code>START /WAIT</code> command in a <code>FOR</code> loop to iterate through all files in a folder and execute the <code>DTUTIL</code> command.</p>
  
  <p>While I know I can return the <code>%ERRORLEVEL%</code> and use it in the main batch process, what I am losing is the specific error message that <code>DTUTIL</code> outputs.</p>
  
  <p>I want to be able to capture that message output, but I have yet to find a way to.  I tried chaining commands by using the <code>&amp;&amp;</code>, <code>||</code> and <code>&amp;</code> concatenation commands.  And I also tried to use <code>&gt;</code> and <code>2&gt;</code> to put the output into a file.  Nothing has given me the desires output.</p>
  
  <p>And to be specific, I'm mainly concerned with when <code>DTUTIL</code> ERRORS and the message is more relevant than the error code alone.</p>
  
  <p>Any help or recommendations would be appreciated.  Here's the code:</p>
  
  <pre><code>@echo off
  
  SET /P SOURCEFOLDER=Enter the Source Folder where the Packages are located:
  SET /P DESTSERVER=Enter the Destination Server:
  SET /P DESTLOCATION=Enter Destination Folder (Leave blank for root):
  
  IF NOT EXIST "%SOURCEFOLDER%\*.dtsx" GOTO NOFILES
  
  FOR /F "usebackq delims==" %%i in (`dir /b "%SOURCEFOLDER%\*.dtsx"`) do (
  ECHO.
  ECHO ^&gt;^&gt;^&gt;^&gt;^&gt;^&gt; Copying %%i to %DESTSERVER%\MSDB\%DESTLOCATION% ^&lt;^&lt;^&lt;^&lt;^&lt;^&lt;^&lt;
  ECHO.
  START /WAIT dtutil /FILE "%SOURCEFOLDER%\%%i" /DESTSERVER %DESTSERVER% /COPY SQL;"%DESTLOCATION%\%%~ni" /QUIET
  ECHO %ERRORLEVEL%
  ECHO.
  )
  GOTO COMPLETE
  
  :NOFILES
  ECHO.
  ECHO *** No SSIS Packages were found.  Please verify the folder location:
  ECHO %SOURCEFOLDER%
  ECHO.
  GOTO END
  
  :COMPLETE
  ECHO.
  ECHO All Packages have been Processed.
  ECHO Please verify that no Error Messages or Warnings were returned.
  ECHO.
  GOTO END
  
  :END
  PAUSE
  </code></pre>