0

I install an apk from Windows PC using

adb install file.apk

The result could be "Success" or one of the Failure messages. How do I determine whether the installation succeeded within the batch file? I want to move the apk of successful installation to another folder.

Yogesh Yadav
  • 404
  • 5
  • 16
  • 2
    What about using as first line `adb install file.apk | %SystemRoot%\System32\find.exe /C /I "Success" >nul` and as second line `if errorlevel 1 goto Failure` with `Failure` being a label in batch file handling installation error condition? The console application `find` searches case-insensitive for `Success` in output lines of `adb` and output the number of lines containing this string which is redirected to device NUL. The exit code is checked by second line which is not 0 if the string `Success` could not be found by `find` in any line. – Mofi Nov 06 '16 at 09:49
  • Possible duplicate of [How to conditionally take action if FINDSTR fails to find a string](http://stackoverflow.com/questions/8530976/how-to-conditionally-take-action-if-findstr-fails-to-find-a-string) – Alex P. Nov 06 '16 at 16:09

1 Answers1

0

adb install file.apk>NUL && echo Action done successfully || echo Action Failed

user2956477
  • 1,208
  • 9
  • 17
  • This returns "Action done successfully" all the time. Please explain why do you expect this to work? – Yogesh Yadav Nov 06 '16 at 18:15
  • Explanation is here http://www.robvanderwoude.com/condexec.php As fas as I have not 'adb' program, tested with ping comand and work fine: If ping target reachable (errorlevel 0) echo "Action done successfully", if unreachable (errorlevel 1) echo "Action Failed" – user2956477 Nov 07 '16 at 00:25
  • this actually works with the latest versions of Android and `adb`. But until very recently `adb` did not set the `errorlevel` in accordance with the result of the command. So for now checking for presence of the "Success" string in the output is the only way for most people. – Alex P. Nov 08 '16 at 01:10