Search code examples
linuxbatch-filevbscriptadbkodi

Batch Script with Input. ADB commands, FireStick


I revised this post to reflect the changes made as per the recommendation of a response.

I would like to run a few lines of adb commands in one batch file.

cd C:\Users\James\AppData\Local\Android\sdk\platform-tools
adb kill-server
adb start-server 

timeout 5
echo Find the IP of the FireStick; Go to Settings, System, About, Network
set /p IPInput = Enter the IP address: 

adb connect %IPInput%
::Error after this line, I am told "error: device '(null)' not found"

adb install "C:\Users\James\Desktop\Kodi on FIreStick\kodi-16.1-Jarvis-armeabi-v7a.apk"
adb install "C:\Users\James\Desktop\Kodi on FIreStick\ace-stream-media-beta-3-1-6-0-apkplz.com.apk"
adb install "C:\Users\James\Desktop\Kodi on FIreStick\Emulators\NES\com.androidemu.nes_61.apk"
adb install "C:\Users\James\Desktop\Kodi on FIreStick\Emulators\SNES\snes9x-ex-1-5-28-en-android.apk"

adb push C:\00_kodi_userdata /sdcard/Android/data/org.xbmc.kodi/files/.kodi/userdata/
adb push C:\00_kodi_addons /sdcard/Android/data/org.xbmc.kodi/files/.kodi/addons/

adb push "C:\00_kodi_downloads" /sdcard/Download

The problem I am facing is the following error: "error: device '(null)' not found"

I know the IP Address is correct that I entered. In fact, I can access the FireStick easily by entering the command in a separate command prompt.

I.e. adb connect 192.168.0.164

Why would it not work here?

Even if I mod the script to the following:

echo Find the IP of the FireStick; Go to Settings, System, About, Network
set /p IPInput = Enter the last three values of the IP address: 

adb connect 192.168.0.%IPInput%

I get an error showing that the IPInput was not used in setting the IP Address. The output just shows:

192.168.0.:5555

What gives?


Solution

  • To those who stumble upon this.

    The command:

    set /p IPInput = Enter the IP address:
    

    Must not contain spaces before/after the equal sign. It will be as follows:

    set /p IPInput=Enter the IP address:
    

    You can then use the command:

    adb connect %IPInput%:5555
    

    To connect to your FireStick

    The top half of my code that will connect to the FireStick (provided adb and its constituents are in your path) is as follows:

    cd %~d0\FireStickAutomation
    adb kill-server
    adb start-server 
    
    timeout 5
    
    @echo off
    echo.
    echo.
    echo .. READ ME .. 
    echo.
    echo.
    echo Find the IP of the FireStick; Go to Settings, System, About, Network
    echo.
    echo.
    echo Make note of the entire string
    echo.
    echo.
    set /p IPInput=Enter the IP address including the dots:
    echo.
    echo.
    
    adb connect %IPInput%:5555