adbPath = ADB工具包文件夹
backupPath = apk安装包文件夹
savePath = 手机保存apk的文件夹

 

@echo off & chcp 65001 & cls & cd /d "%~dp0"
setlocal enabledelayedexpansion
REM adb tool path
set "adbPath=G:\Desktop\adb"
REM backup path
set "backupPath=G:\Desktop\apk"
REM save path
set "savePath=/sdcard/apk"
mkdir "%backupPath%" >nul 2>nul
set "path=%path%;%adbPath%"
REM counter
set "count=0"
for %%i in ("%backupPath%\*.apk") do (
    set /a "count+=1"
    echo !count!:%%~nxi
    REM check exist
    adb shell if [ -f '%savePath%/%%~nxi' ];then echo true;else echo false;fi | findstr /i "true" >nul 2>nul && (
        REM exist
        echo skip push
    ) || (
        REM not exist
        REM push to %savePath%
        echo pushing...
        adb push "%%i" "%savePath%/%%~nxi" >nul 2>nul
        echo push done.
    )
    REM copy apk to /data/local/tmp
    adb shell cp '%savePath%/%%~nxi' 'data/local/tmp'
    REM install apk
    echo install ...
    adb shell pm install 'data/local/tmp/%%~nxi'
    REM del temp apk
    adb shell rm -rR 'data/local/tmp/%%~nxi'
    echo ----------------------------------------------------
)
pause&exit