::visit Rootjunky.com

::Set our Window Title
@title Amazon Fire TV Tool

::Set our default parameters
@echo off
color 0b



:menuLOOP

	call:header
	::Print our header
	::call:header
	
	::Load up our menu selections
	echo.--------------------------------------------------------------------------------
	for /f "tokens=1,2,* delims=_ " %%A in ('"C:/Windows/system32/findstr.exe /b /c:":menu_" "%~f0""') do echo.  %%B  %%C
	
	call:printstatus

	set choice=
	echo.&set /p choice= Please make a selection or hit ENTER to exit: ||GOTO:EOF
	echo.&call:menu_%choice%
	
GOTO:menuLOOP

:menu_1 Root Amazon Fire TV with Towel Root
cls
color 0b
echo.--------------------------------------------------------------------------------
echo. To root your Amazon Fire TV with Towelroot app click any 
echo. key to continue and the files will be pushed to your deivce
echo.--------------------------------------------------------------------------------
pause
adb install towelrootV3.apk
adb install Superuser.apk
adb install Busybox Installer4.1.apk
echo. Root apps are now installed
echo. to launch app go to settings/applications
echo. run towel root app then run supersu
echo. and you are now rooted
echo.--------------------------------------------------------------------------------
echo. also recommend running busybox installer
	set choice=
	echo.&set /p choice= hit ENTER to return to start: ||GOTO:EOF
	echo.&call:menu_%choice%
color 0b	
cls	
GOTO:EOF

:menu_2 Install FiredTV launcher 
cls
color 0b	
echo.--------------------------------------------------------------------------------
adb install firedtvlauncher1.0.3.apk
echo. FiredTV laucher is now installed
echo. launcher it be pressing the home button
set choice=
	echo.&set /p choice= hit ENTER to return to start: ||GOTO:EOF
	echo.&call:menu_%choice%
color 0b	
cls	
GOTO:EOF

:menu_3 Disable Fire TV OTA Updates                      ( Root Rewuired )
cls
color 0b
echo.--------------------------------------------------------------------------------
echo. This will Disable OTA Updates on the Fire TV
echo.--------------------------------------------------------------------------------
pause
adb shell su -c "pm disable com.amazon.dcp"
echo. OTA Updates Disabled
	set choice=
	echo.&set /p choice= hit ENTER to return to start: ||GOTO:EOF
	echo.&call:menu_%choice%
color 0b	
cls	
GOTO:EOF

:menu_4 Firmware Up or Downgrade script        ( Root & busybox Required )
cls
color 0b
echo.--------------------------------------------------------------------------------
echo. This Requires Root and Busybox to it to work also make sure you
echo. download the firmware and place it in this folder also rename
echo. it to update.zip then you can run the script
echo. if you dont have this done already then close program and restart
echo. or click any button to continue
echo.--------------------------------------------------------------------------------
pause
echo. you will need to grant root to adb shell now
echo. on the Amazon Fire TV
adb shell su -c "chmod 777 /cache"
adb shell su -c "chmod 777 /cache"
adb shell su -c "chmod 777 /cache/recovery"
adb shell su -c "echo '--update_package=/cache/update.zip' > /cache/recovery/command"
echo.--------------------------------------------------------------------------------
echo. sending update.zip to device this will take some
echo. time please wait depending on your network speed
adb push update.zip /cache
echo.--------------------------------------------------------------------------------
echo. if your Amazon Fire TV has booted to
echo. recovery and is installing update then
echo. it is safe to close this program 
adb reboot recovery
timeout 8 > nul
	set choice=
	echo.&set /p choice= hit ENTER to return to start: ||GOTO:EOF
    echo.&call:menu_%choice%
color 0b	
cls
GOTO:EOF

:header  
cls        
color 0e
echo.--------------------------------------------------------------------------------
echo.				   RootJunkys
echo. 		     Firmwade Restore Tool brought to you by
echo. 		     Rootjunky.com with help from Matt Groff.
echo. 		     also firetv news for terminal commands.
echo.--------------------------------------------------------------------------------
echo.
adb kill-server
adb start-server
echo.--------------------------------------------------------------------------------
echo. First you must turn on ADB DEBUGGING in the fire tv settings
echo. Enter IP address from Amazon Fire TV in
echo. settings/system/about/network IP address number 
echo. example 000.00.0.0 then press enter
echo.--------------------------------------------------------------------------------
echo Enter IP Number
set /p IP=""
adb connect "%IP%"
adb devices
timeout 8 > nul
cls	
color 0b
GOTO:EOF

:printstatus
echo.
echo. Time to unlock the Beast
echo.--------------------------------------------------------------------------------
GOTO:EOF

