3

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

1615903
  • 32,635
  • 12
  • 70
  • 99
Simon
  • 147
  • 2
  • 10

3 Answers3

5

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
Dmitry Sokolov
  • 3,118
  • 1
  • 30
  • 35
3

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

Mi-Creativity
  • 9,554
  • 10
  • 38
  • 47
Arvin yang
  • 31
  • 3
1

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)

Mehdi Khademloo
  • 2,754
  • 2
  • 20
  • 40