title: Display message based on error returned when starting service with batch file?
body: <p>Perhaps I am not searching with the correct terms, but I can't seem to find the answer anywhere. I am trying to get a specific message to be displayed when a service errors out with "...due to a logon failure", but I don't know what I need to have entered into the batch file. With the help of <a href="https://stackoverflow.com/questions/3325081/">this article</a>, this is what I have so far: </p>
  
  <pre><code>@echo off
  echo This will start your MYSERVICES. If you do not wish to do this, please close this window, otherwise: 
  pause
  for /F "tokens=3 delims=: " %%H in ('sc query "MYSERVICE1" ^| findstr "        STATE"') do (
    if /I "%%H" NEQ "RUNNING" (
     NET START "MYSERVICE1"
    )
  )
  for /F "tokens=3 delims=: " %%H in ('sc query "MYSERVICE2" ^| findstr "        STATE"') do (
    if /I "%%H" NEQ "RUNNING" (
     NET START "MYSERVICE2"
    )
  )
  @echo off
  echo Your services should now be started! 
  
  @echo off
  
  echo If any errors came up or you still cannot get into your software, be sure to give Tech Support a call at 1-800-xxx-xxxx. 
  
  @echo off
  echo To close this window:
  pause
  </code></pre>
  
  <p>It works fine to start the services when they are not running, but I want the line for</p>
  
  <p>@echo off</p>
  
  <p>echo Your services should now be started!</p>
  
  <p>to return a different message if the previous command ends up erring out with the 1069 error for "...due to a logon failure". Is there any way to do this? Possibly by querying the error? I'm new to this so I'm not sure what I need to be looking at. </p>
  
  <p>Thanks!</p>