@echo off
echo.
echo **************************************************
echo Easy root for LG G2
echo Supports the following carriers:
echo  ATT, TMO, VZW, KT, SKT, RGS, BELL, TLS and OPEN
echo By IOMonster (thecubed on XDA)
echo See http://tinyw.in/mXhw for details
echo **************************************************
echo.
echo.
echo Original root idea from http://optimusforums.com/threads/how-to-root-the-lg-g2-f320.8846/
echo.
echo.
pause
echo Looking for device...
.\adb.exe wait-for-device
echo Determining carrier...
for /f %%i in ('.\adb.exe shell getprop ro.build.target_operator') do set RESULT=%%i
if %RESULT%==ATT GOTO ATTTMORoot
if %RESULT%==TMO GOTO ATTTMORoot
if %RESULT%==VZW GOTO VZWRoot
if %RESULT%==KT GOTO KTRoot
if %RESULT%==RGS GOTO D803Root
if %RESULT%==BELL GOTO D803Root
if %RESULT%==TLS GOTO D803Root
if %RESULT%==OPEN GOTO ATTTMORoot
REM if %RESULT%==SKT GOTO ATTTMORoot

echo.
echo.

echo No matching phone found. Got %RESULT% from ADB.
pause

:ATTTMORoot
echo Found ATT, TMO, SKT, or D802 phone!
echo Pushing g2_security...
echo.
.\adb.exe push g2_security /sdcard/g2_security
GOTO RootStep2

:VZWRoot
echo Found VZW phone!
echo.
echo Checking OTA version...
for /f %%i in ('.\adb.exe shell getprop ro.lge.swversion') do set OTAVER=%%i
if %OTAVER%==VS98010B GOTO VZWStockRoot
if %OTAVER%==VS98011A GOTO VZWOTARoot
GOTO VZWNoMatch

:VZWNoMatch
echo.
echo.
echo We don't have an unlock for this Verizon OTA version yet.
echo Your phone is running %OTAVER% .
echo.
echo Please ask IOMonster or TheCubed to look into this
echo This program will now exit.
pause
exit


:VZWOTARoot
echo Found OTA VZW phone!
echo Pushing VZW ytiruces_1a ...
.\adb.exe push ytiruces_1a_vzw /sdcard/ytiruces_1a
GOTO RootStep2


:VZWStockRoot
echo Found non-OTA VZW phone!
echo Pushing VZW g2_security...
.\adb.exe push g2_security_vzw /sdcard/g2_security
GOTO RootStep2

:KTRoot
echo Found KT F320k phone!
echo Pushing ytiruces_1a ...
.\adb.exe push ytiruces_1a /sdcard/ytiruces_1a
GOTO RootStep2

:D803Root
echo Found D803 phone!
echo Pushing D803 ytiruces_1a ...
.\adb.exe push ytiruces_1a_d803 /sdcard/ytiruces_1a
GOTO RootStep2

:RootStep2
echo.
echo.
echo *******************************************************
echo Now, please unplug usb, go to developer options and 
echo disable USB debugging and re-enable it.
echo Once you've done that, re-plug your usb...
echo *******************************************************
pause
echo Waiting for device...
.\adb.exe wait-for-device
echo Now it's time to install su and superuser.
echo.
echo Please note! This will trip LG's rootchecker!
echo.
echo This means your phone will show ROOTED in the settings menu,
echo and in the LG Download mode.
echo.
echo If you do not want to possibly invalidate your warranty
echo press CTRL-C to stop this script.
echo You will have a rooted ADB, but no apps on the phone will be able
echo to access root functions.
echo.
pause
echo.
echo.
echo Mounting system RW and pushing SU, then remounting system RO again
.\adb.exe shell "mount -o remount,rw /system"
.\adb.exe push su /system/xbin/su
.\adb.exe shell "chown 0.0 /system/xbin/su;chmod 06755 /system/xbin/su;sync;mount -o remount,ro /system"
echo Installing superuser
.\adb.exe install superuser.apk
echo.
echo.
echo ***************************************************
echo                       Done.
echo ***************************************************
echo.
echo Please check the above for any errors and let me know if you run into any issues.
echo Enjoy your phone!
pause