I want to write a batch file that help me to installing apk files when I double click on any apk file
for example when I click on apk file myBatchFile.bat execute
what should be in myBatchFile.bat
adb install what?
thanks
I want to write a batch file that help me to installing apk files when I double click on any apk file
for example when I click on apk file myBatchFile.bat execute
what should be in myBatchFile.bat
adb install what?
thanks
First, backup the HKEY_CURRENT_USER\SOFTWARE\Classes
registry hive. So you can restore settings if something goes wrong during testing of .bat
files.
You need to install the shell handler of .apk
files. The handler is a .bat
file, say MyApkInstaller.bat
. When you double click on a .apk
file in Windows Explorer the handler MyApkInstaller.bat
will be run and the .apk
file name will be passed to the handler.
@echo off
echo Installing %1...
adb install %1 && echo Done || echo Failed
pause
The script that will install/uninstall the handler into Windows Registry
@echo off
setlocal
set _progId=MyApkInstaller
set _handler=MyApkInstaller.bat
if not "%1"=="" goto uninstall
:install
echo Installing...
reg add HKCU\Software\Classes\.apk\OpenWithProgIds /v %_progId% /t REG_SZ /f
reg add HKCU\Software\Classes\%_progId%\Shell\Open\Command /ve /t REG_SZ /d "%~dp0%_handler% ""%%1""" /f
goto finish
:uninstall
echo Uninstalling...
reg delete HKCU\Software\Classes\.apk
reg delete HKCU\Software\Classes\%_progId%
:finish
endlocal
You can write these into your xxx.bat
@echo %1
adb install -r %1
pause
Setting the environment variables is necessary, open the xxxx.apk by choosing the way of xxx.bat
The adb
can install the *.apk
on emulator as follows:
adb install PATH
so, you can simply create a batch file like this:
@echo off
echo installing your application...
adb install %1
and after save it, choose this batch file for default application of *.apk
files. (apk file in explorer > right click > properties > change > YOUR_BATCH_FILE)