title: Error handling of batch script with adb commands
body: <p>I want to make a simple batch script to install apk on android device. I can do this if Debugging is on and Device drivers are installed.</p>
  
  <p>When device drivers are not installed it show error device not found and when debug acces is not allowed it show please allow usb debug from device.</p>
  
  <p>I want to know how i can switch between these errors i want to start adbdriverinstaller.exe if no drivers are installed and if it requires usb debug access then just echo please allow usb debug access form mobile.</p>
  
  <p>Here is my code </p>
  
  <pre><code>@ECHO off
  
  echo Writing Configuration... 
  
  adb push Config.cfg /sdcard/Config.cfg
  if errorlevel 1 echo Failed with error #%errorlevel%.
  
  //here i want to switch between error types (if no device found error or allow usb debug access error)
  
  if errorlevel 1 start "" AdbDriverInstaller.exe
  if errorlevel 1 PAUSE
  if errorlevel 1 EXIT
  
  echo Installing Apk... 
  adb install -r myApk.apk
  
  echo opening apk
  
  adb shell am start -n com.myApk.myApk/.myApkActivity
  
  PAUSE
  </code></pre>
  
  <p>what i want to do is 
  if </p>
  
  <pre><code>error: device not found
  error: device not found
  </code></pre>
  
  <p>error arises then simply open adbdriver installer and if</p>
  
  <pre><code>error: device unauthorized. Please check the confirmation dialog on your device.
  
  error: device unauthorized. Please check the confirmation dialog on your device.
  </code></pre>
  
  <p>Error arises than simply display please allow USB debug access from mobile.</p>
  
  <p><img src="https://i.stack.imgur.com/3zg7v.png" alt="enter image description here"></p>