Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :: Released under the GNU General Public License version 3 by J2897.
- @echo OFF
- setlocal
- REM Possible locations to find ADB.
- set "ADB[1]=C:\Android\adb.exe"
- set "ADB[2]=C:\Program Files\Android\android-sdk\platform-tools\adb.exe"
- set "ADB[3]=C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe"
- REM Find ADB.
- if exist "%ADB[1]%" (set "ADB=%ADB[1]%")
- if exist "%ADB[2]%" (set "ADB=%ADB[2]%")
- if exist "%ADB[3]%" (set "ADB=%ADB[3]%")
- REM Did we find ADB?
- if not defined ADB (
- echo Android Debug Bridge not found. Get it from here...
- echo http://developer.android.com/sdk/index.html
- goto :End
- )
- if [%1]==[] (
- echo Drop some APKs on top of this file to install them on your SD Card.
- goto :End
- )
- REM Start a fresh ADB daemon.
- "%ADB%" kill-server
- "%ADB%" -d devices -l || goto :End
- REM Unable to use double-quotes. So prepare to temporarily change directory. It's future-proof this way.
- REM If the parentheses in ADB[3] cause problems for 64-Bit users, output and iterate a temporary text file, or change the directory permanently.
- for /f "delims=" %%A in ("%ADB%") do (
- set "ADB_FOLDER=%%~dA%%~pA"
- set "ADB_FILE=%%~nA"
- )
- REM Is the device connected?
- pushd "%ADB_FOLDER%"
- for /f "delims=" %%A in ('%ADB_FILE% -d devices ^| find "" /v /c') do (set "LINE_COUNT=%%A")
- popd
- if %LINE_COUNT% LSS 3 (
- echo Connect your device via USB and try again.
- goto :End
- )
- :Getfile
- echo.
- if [%1]==[] (goto :End)
- set "FILENAME=%~nx1"
- REM Check the file extension.
- for /f "delims=" %%A in ("%FILENAME%") do (set "EXTENSION=%%~xA")
- if /i not "%EXTENSION%"==".apk" (
- echo [%FILENAME%] is not an APK.
- goto :Skip
- )
- echo [%FILENAME%]
- set LOCAL="%1"
- set REMOTE="/storage/sdcard0/APKs/%FILENAME%"
- echo Sending the APK to the device...
- "%ADB%" -d push %LOCAL% %REMOTE% || goto :Skip
- echo Installing the app...
- "%ADB%" -d shell pm install -s %REMOTE% || goto :Skip
- echo Removing the APK...
- "%ADB%" -d shell rm %REMOTE% || goto :Skip
- echo Done.
- :Skip
- shift
- goto :Getfile
- :End
- echo.
- echo Finished!
- echo.
- endlocal
- pause
Add Comment
Please, Sign In to add comment