-1

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?

James Hayek
  • 643
  • 3
  • 10
  • 35
  • Btw, why was this down voted? I did much research prior to posting, and did my best to make the question clear. Please let me know what I need to do to be a more informed user of StackOverFlow – James Hayek Aug 28 '16 at 17:29

2 Answers2

0

You're trying to use VBScript code inside a batch file. That's not going to work¹. In batch you can prompt for user input via the set command:

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

¹ Unless you're building some kind of Frankenscript, which I strongly recommend not to do.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
  • I used the following lines: "echo Find the IP of the FireStick; Go to Settings, System, About, Network set /p IPInput=Enter the IP address:" in place of the original lines 4 and 5. The command prompt closes out, I can not see where the error is but I know that there was an error. – James Hayek Aug 28 '16 at 16:59
  • Well, open a command prompt and run the script from there, so it doesn't close automatically. – Ansgar Wiechers Aug 29 '16 at 08:48
  • Or use the cmd /k flag to keep the window open – James Hayek Aug 29 '16 at 12:19
  • Did you get it working? Mark the question "Answered" if the answer helped. – Randy Schuman Aug 31 '16 at 05:15
0

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
James Hayek
  • 643
  • 3
  • 10
  • 35
  • I tried this and am getting Error:More than 1 device/emulator. Any ideas? – Brandon Apr 12 '18 at 01:17
  • @Brandon open a terminal window and “adb kill” Try to enter everything manually, then write the batch file. I.e. adb kill, then adb start-server, then adb connect – James Hayek Apr 12 '18 at 01:22
  • When I do it manually and do kill then start then connect it tells me that the ip address of the firestick is already connected. I do have it connected to my computer through USB, when I disconnect it though it doesnt find the firestick at all (I guess you have to hard wire and cant count on wifi?) – Brandon Apr 12 '18 at 13:41