echo off
SET scrver=ver 1.02
SET moddate=2015.9.24
REM Script now uninstalls GravityBox as well

REM Test to catch when script is "Run as Administrator"
REM Windows will change current dir to c:\WINDOWS\SYSTEM, so we need to
REM change back to folder where script resides
REM %0 is the drive/path/filename of this batch file. 
REM %~dp0 expands to the drive and path of this batch file

echo **%0 Started from %cd% - Date=%date% Time=%time% OS=%os% Username=%username% > log1.txt
echo **Contents of %cd%: >> log1.txt
dir /B >> log1.txt
REM Kill any running adb processes
taskkill /f /im adb.exe >NUL 2>NUL  
color E
cls
echo.
echo             ***********************************************
echo             *  RemoveXFandInstaller.BAT       %scrver%    *
echo             *       Xposed Framework uninstaller          * 
echo             *          for Teclast X98 Air II/3G          *
echo             *                                             *
echo             *              modified                       *
echo             *              %moddate%  TecKnight           *
echo             ***********************************************
echo.
echo IMPORTANT !!
echo  - This uninstaller is only for X98 Air devices running Android 5.0 
echo  - This script should remove any version of Xposed Framework
echo  - If you are running any other version of Android, abort by pressing CTRL=C
echo  - Your BATTERY must be charged to 50%% or higher !!
echo  - Your X98 device must be booted into Android and connected to this PC via USB
echo  - On X98 device-"Settings->Developer options->USB debugging" must be checked
echo.
echo If all above requirements are met, press ENTER to proceed
echo Otherwise, press CTRL-C to abort
pause > nul
echo '
echo ' Connecting to X98 Air device..
echo ' Connecting to X98 Air device.. >> log1.txt
echo '
echo **running "adb devices" output= > log2.txt
adb devices >> log2.txt
type log2.txt
adb wait-for-devices
echo '
echo ' Pushing Xposed Framework uninstaller binary ..
echo ' Pushing Xposed Framework uninstaller binary .. >> log2.txt
echo '
echo **running "adb push binaries\uninstaller /data/local/tmp" output= >> log2.txt
adb push binaries\uninstaller /data/local/tmp  2>> log2.txt
echo '
echo **running "adb shell su -c chmod 755 /data/local/tmp/uninstaller" output= > log3.txt
adb shell "su -c chmod 755 /data/local/tmp/uninstaller" >> log3.txt
echo '
echo ' Removing Xposed Framework ..
echo ' Removing Xposed Framework .. >> log3.txt
echo '
echo **running "adb shell su -c /data/local/tmp/uninstaller" output= > log4.txt
adb shell "su -c /data/local/tmp/uninstaller" >> log4.txt
echo '
echo ' Uninstalling Xposed installer ..
echo ' Uninstalling Xposed installer .. >> log4.txt
echo '
echo **running "adb shell su -c rm -r /system/app/Xposed" output= >> log4.txt
adb shell "su -c rm -r /system/app/Xposed" >> log4.txt

echo **running "adb uninstall de.robv.android.xposed.installer" output= >> log4.txt
adb uninstall de.robv.android.xposed.installer >> log4.txt

echo **running "adb uninstall com.ceco.lollipop.gravitybox" output= >> log4.txt
adb uninstall com.ceco.lollipop.gravitybox >> log4.txt

echo '
echo ' Done, rebooting ..
echo ' Done, rebooting .. >> log4.txt
echo '
taskkill /f /im adb.exe >NUL 2>NUL
copy /B log1.txt XFULog.txt >NUL
if exist log2.txt copy /B XFULog.txt+log2.txt XFULog.txt >NUL
if exist log3.txt copy /B XFULog.txt+log3.txt XFULog.txt >NUL
if exist log4.txt copy /B XFULog.txt+log4.txt XFULog.txt >NUL
del log*.txt

adb reboot