打开
@echo offsetlocal EnableDelayedExpansionadb devices>nuladb devicesset num=0set apkFileName=%~nx1set apkpath=%1echo ID Brand Model androidOS apiLevel resolution SerialNum>phoneinfo.txtFOR /f "skip=1" %%a in ('adb devices^|findstr device') do ( adb -s %%a shell cat /system/build.prop > phone.info FOR /F "tokens=1,2 delims==" %%a in (phone.info) do ( IF %%a==ro.build.version.release set androidOS=%%b IF %%a==ro.build.version.sdk SET apiLevel=%%b IF %%a==ro.product.model SET model=%%b IF %%a==ro.product.brand SET brand=%%b ) FOR /f "tokens=3 delims=), " %%a in ('adb -s %%a shell dumpsys window^|findstr mUnrestrictedScreen^|findstr /V OriginalmUnrestrictedScreen') do SET resolutionratio=%%a set /a num+=1 set "brand=!brand: =!" if "!model!"=="" (set model=Null_ ) set "model=!model: =!" set SerialNum=%%a echo !num! !brand:~0,-1! !model:~0,-1! !androidOS:~0,-1! !apiLevel:~0,-1! !resolutionratio:~0,-1! %%a>>phoneinfo.txt set model=Null)FOR /f "delims=" %%a in (phoneinfo.txt) do echo %%aECHO.for /f "delims=:" %%h in ('findstr /n .* phoneinfo.txt') do ( set line=%%h)IF %line%==2 ( set ID=1 ) else ( ECHO **************************** Install App Note: ***************************** ECHO If you want to install app to one device ,please enter the device ID num. ECHO If you want to install app to all devices,please enter the device ID num:100 ECHO. set /p ID=Please enter the device ID num: echo You enter the device ID num:!ID! FOR /F "skip=1 tokens=1,7 delims= " %%a in (phoneinfo.txt) do ( IF %%a==!ID! set SerialNum=%%b ))IF %ID% gtr !num! ( IF %ID% EQU 100 ( FOR /f "skip=1" %%a in ('adb devices^|findstr device') do (call :installapk %%a) ) else ( ECHO You enter the wrong number, auto exit... && CHOICE /T 5 /C yc /D y /n )) else ( call :installapk !SerialNum!)DEL phoneinfo.txt /a/f/qgoto :eof:installapkset serialnum=%1adb -s %serialnum% shell cat /system/build.prop > phone.infoFOR /F "tokens=1,2 delims==" %%a in (phone.info) do ( IF %%a==ro.build.version.release SET androidOS=%%b IF %%a==ro.build.version.sdk SET apiLevel=%%b IF %%a==ro.product.model SET model=%%b IF %%a==ro.product.brand SET brand=%%b)DEL phone.info /a/f/qpython E:\GetSVNNumTool.py %apkpath%FOR /F "tokens=1,2 delims==" %%a in (E:\tempinfo.txt) do ( IF %%a==apkFileMd5 SET apkFileMd5=%%b IF %%a==LastChangedSVNNum SET apkSVN=%%b IF %%a==apkFileChannel SET apkChannel=%%b)ECHO The Android Phone Serial Number . . : %serialnum%ECHO The Android Phone Brand . . . . . . : %brand%if "%model%"=="" (ECHO The Android Phone Model . . . . . . : Null/not get) else ( ECHO The Android Phone Model . . . . . . : %model%)ECHO The Android Phone OS Version. . . . : Android %androidOS%ECHO The Android Phone SDK API Level . . : %apiLevel%FOR /f "tokens=3 delims=), " %%a in ('adb -s %serialnum% shell dumpsys window^|findstr mUnrestrictedScreen^|findstr /V OriginalmUnrestrictedScreen') do SET resolutionratio=%%aECHO The Android Phone Display Ratio . . : %resolutionratio%ECHO.FOR /f "tokens=3 delims==, " %%a in ('aapt dump badging %apkpath%^|findstr package:') do SET PackageName=%%aSET PackageName=%PackageName:~1,-1%FOR /f "tokens=2 delims=:" %%a in ('aapt dump badging %apkpath%^|findstr application-label:') do SET AppName=%%aSET AppName=%AppName:~1,-1%ECHO The Android App Chinese Name. . . . : %AppName%ECHO The Android App File Name . . . . . : %apkFileName%ECHO The Android App File MD5 Value. . . : %apkFileMd5%if "%apkSVN%"=="" (ECHO The Android App Last Changed SVN: Null/not get) else ( ECHO The Android App Last Changed SVN. . : %apkSVN%)if "%apkChannel%"=="" (ECHO The Android App File ChannelNum: Null/not get) else ( ECHO The Android App File Channel Num. . : %apkChannel%)FOR /f "tokens=2 delims=:, " %%a in ('aapt dump badging %apkpath%^|findstr sdkVersion:') do SET minSdkVersion=%%aSET minSdkVersion=%minSdkVersion:~1,-1%ECHO The Android App minSdkVersion . . . : %minSdkVersion%FOR /f "tokens=5 delims=), " %%a in ('aapt list -v -a %apkpath%^|findstr android:debuggable') do SET androiddebuggablestate=%%aif "%androiddebuggablestate%"=="0x0" (ECHO The Android App debuggable mode . . : False) else (if "%androiddebuggablestate%"=="0xffffffff" (ECHO The Android App debuggable mode . . : True) else (ECHO The Android App debuggable mode . . : Unkown))FOR /f "tokens=7 delims==, " %%a in ('aapt dump badging %apkpath%^|findstr package:') do SET VersionName=%%aSET VersionName=%VersionName:~1,-1%ECHO The Android App Version Name. . . . : %VersionName%FOR /f "tokens=5 delims==, " %%a in ('aapt dump badging %apkpath%^|findstr package:') do SET VersionCode=%%aSET VersionCode=%VersionCode:~1,-1%ECHO The Android App Version Code. . . . : %VersionCode%ECHO The Android App Package Name. . . . : %PackageName%FOR /f "tokens=3 delims==, " %%a in ('aapt dump badging %apkpath%^|findstr launchable-activity:^|findstr /V com.squareup.leakcanary') do SET LaunchableActivityName=%%aSET LaunchableActivityName=%LaunchableActivityName:~1,-1%ECHO The Android App Main Activity . . . : %LaunchableActivityName%ECHO.ECHO The BAT Tool is uninstalling %AppName%adb -s %serialnum% uninstall %PackageName%ECHO The BAT Tool is installing %AppName%,please wait for servel seconds...adb -s %serialnum% install %apkpath%ECHO.ECHO The BAT Tool is opening %AppName%,please wait for servel seconds...adb -s %serialnum% shell am start -n %PackageName%/%LaunchableActivityName%ECHO.goto :eof