::visit Rootjunky.com

::Set our Window Title
@title Moto E auto Root

::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 your Moto E                         (unlocked bootloader required)
cls
color 0b
echo.--------------------------------------------------------------------------------
echo [*] Big thanks to ChainFire for supersu app
echo [*] Make sure USB Debugging is enabled on your device
echo [*] this will push Supersu and then temp boot into recovery.
echo [*] you will keep stock android recovery
echo.--------------------------------------------------------------------------------
echo [*] press any key to start
pause > nul
echo [*]
echo [*] waiting for device
adb wait-for-device...
adb push SuperSU-v2.01.zip /sdcard/download
echo.--------------------------------------------------------------------------------
echo [*] supersu is pushed to device press any key to enter recovery
echo.--------------------------------------------------------------------------------
pause > nul
adb reboot bootloader
fastboot.exe boot moto_e_twrp2.7.2.0_v2.2.img
echo [*]
echo.--------------------------------------------------------------------------------
echo [*] select install, downloads, SuperSU-v2.01.zip
echo [*] Next swipe to install Supersu.zip
echo [*] Select reboot then system select it. device will reboot
echo.--------------------------------------------------------------------------------
echo [*] Press any key to finish this script. ROOTJUNKY OUT

	set choice=
	echo.&set /p choice= hit ENTER to return to start: ||GOTO:EOF
	echo.&call:bootsubmenu_%choice%
cls	
GOTO:EOF

:menu_2    Flash TWRP recovery                      (unlocked bootloader required)
cls
color 0b
echo.--------------------------------------------------------------------------------
echo [*] Big thanks to cybojenix for compiling TWRP for the Moto E
echo [*] Make sure USB Debugging is enabled on your device
echo [*] This will flash Team win / TWRP recovery
echo [*] to your device from fastboot. 
echo.--------------------------------------------------------------------------------
echo [*] Press any button to continue
pause > nul
echo [*] waiting for device
adb wait-for-device
echo [*] device found
adb reboot bootloader
fastboot.exe flash recovery moto_e_twrp2.7.2.0_v2.2.img
fastboot.exe boot moto_e_twrp2.7.2.0_v2.2.img
echo.--------------------------------------------------------------------------------
echo [*] If you want to keep TWRP recovery installed after
echo [*] a reboot select reboot system and choose yes
echo [*] to keeping TWRP recovery
echo.--------------------------------------------------------------------------------
echo [*] RootJunky OUT
	set choice=
	echo.&set /p choice= hit ENTER to return to start: ||GOTO:EOF
	echo.&call:bootsubmenu_%choice%
color 0b	
cls	
GOTO:EOF

:menu_3    Flash stock Android 4.4.2 recovery       (unlocked bootloader required)
cls
color 0b
echo.--------------------------------------------------------------------------------
echo [*] Before continuing, ensure USB debugging is enabled
echo [*] This will flash stock recovery to your
echo [*] device from fastboot then reboot back to system
echo.--------------------------------------------------------------------------------
echo [*] press any button to continue
pause > nul
echo [*] waiting for device
adb wait-for-device
echo [*] device found
adb reboot bootloader
fastboot.exe flash recovery 4.4.2-recovery.img
fastboot reboot
echo [*] RootJunky OUT
	set choice=
	echo.&set /p choice= hit ENTER to return to start: ||GOTO:EOF
	echo.&call:bootsubmenu_%choice%
color 0b	
cls	
GOTO:EOF

:header  
cls        
color 0e
echo.--------------------------------------------------------------------------------
echo. 				    RootJunkys
echo. 				Moto E Auto Root 
echo. 				       And
echo. 			       TWRP Recovery Flash
echo.--------------------------------------------------------------------------------
echo.
adb kill-server
adb start-server
echo.--------------------------------------------------------------------------------
adb devices
timeout 6 > nul
cls	
color 0b
GOTO:EOF

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

