使用adb命令批处理安装&卸载apk
- @echo off
- title adb install [by Join]
- rem 定义adb路径
- rem set adb_path=C:\Program Files\Wandoujia2
- set adb_path=E:\zhao\environment\android-sdk-windows\platform-tools
- rem adb.exe存在判断及处理
- if exist %adb_path%\adb.exe (goto :handle) else (echo abd.exe路径不正确,请修正!&goto :end)
- rem adb.exe存在时的处理
- :handle
- rem 无文件拖至bat时
- if "%~1"=="" echo 请将apk直接拖放至bat文件!&goto :end
- echo 注意事项
- echo 1、已安装过的apk请先用uninstall.bat卸载!
- echo 2、支持中文名称apk的安装(以替换名称的方式)!
- echo 3、支持多apk文件安装(即选中所有你要安装的apk拖动至此bat上)!
- rem path增加adb路径
- set path=%adb_path%;%path%
- rem 多文件时的遍历
- :main
- setlocal enabledelayedexpansion
- if not "%~1"=="" (
- echo.
- rem 文件后缀名判断
- if /i "%~x1"==".apk" (
- rem 文件名称替换后install
- set dir=%~dp1
- set file=%~nx1
- ren "%~1" install.apk
- echo 安装"!dir!!file!"...
- adb install "!dir!install.apk"
- ren "!dir!install.apk" !file!
- ) else (
- echo 文件类型错误:不支持%~x1!
- )
- shift /1
- goto :main
- )
- :end
- echo.
- pause
- @echo off&setlocal enabledelayedexpansion
- title adb uninstall [by Join]
- rem 定义adb路径
- rem set adb_path=C:\Program Files\Wandoujia2
- set adb_path=E:\zhao\environment\android-sdk-windows\platform-tools
- rem adb.exe存在判断及处理
- if exist %adb_path%\adb.exe (goto :handle) else (echo abd.exe路径不正确,请修正!&goto :end)
- rem adb.exe存在时的处理
- :handle
- rem path增加adb路径
- set path=%adb_path%;%path%
- echo 注意事项
- echo 1、请将需要卸载的apk包名,写入同目录的package.txt!
- echo 2、不知道apk包名?可以用如下几种简单方式查看。
- echo 1)直接解压apk,得到AndroidManifest.xml,用记事本打开就行!
- echo 能看到类似*package *manifest *org.join.xxx的内容--
- echo 2)使用apktool,反编译得到apk资源文件,查看AndroidManifest.xml!
- echo 最上部manifest标签内package="org.join.xxx"属性内内容
- rem package.txt存在判断及处理
- if exist package.txt (
- rem 遍历文件多行
- for /f %%l in (package.txt) do (
- set /a num+=1
- echo.&echo 卸载"%%l"...
- call adb uninstall %%l
- )
- ) else (
- echo.&echo package.txt不存在!
- )
- :end
- echo.
- pause
恩,还有adb install前你可以增加参数决定怎么安装,如下:
adb install [-l] [-r] [-s] <file> - push this package file to the device and install it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its data)
('-s' means install on SD card instead of internal storage)