@ECHO OFF
ECHO. ***Mounting system RW...***
adb root
adb remount

ECHO. ***Copying and creating files...***
adb shell mkdir /system/app/SuperSU
adb shell mkdir /system/bin/.ext
adb push common/Superuser.apk /system/app/SuperSU/SuperSU.apk
adb push common/install-recovery.sh /system/etc/install-recovery.sh
adb push armv7/su /system/xbin/su
adb push armv7/su /system/xbin/daemonsu
adb push armv7/su /system/bin/.ext/.su
adb push armv7/supolicy /system/xbin/supolicy
adb push armv7/libsupol.so /system/lib/libsupol.so
adb shell touch /system/etc/.installed_su_daemon
adb shell mv /system/bin/app_process32 /system/bin/app_process32_original
adb shell mv /system/bin/app_process /system/bin/app_process_original

ECHO. ***Setting permissions...***
adb shell chmod 0644 /system/app/SuperSU/SuperSU.apk /system/lib/libsupol.so /system/etc/.installed_su_daemon
adb shell chmod 0755 /system/etc/install-recovery.sh /system/xbin/su /system/bin/.ext/.su /system/xbin/daemonsu /system/xbin/supolicy
adb shell chcon u:object_r:system_file:s0 /system/app/SuperSU/SuperSU.apk /system/xbin/su /system/bin/.ext/.su /system/xbin/daemonsu
adb shell chcon u:object_r:system_file:s0 /system/xbin/supolicy /system/lib/libsupol.so /system/etc/.installed_su_daemon
adb shell chcon u:object_r:zygote_exec:s0 /system/bin/app_process32_original
adb shell chcon u:object_r:zygote_exec:s0 /system/bin/app_process_original

ECHO. ***Setting up symlinks...***
adb shell ln -s /system/etc/install-recovery.sh /system/bin/install-recovery.sh
adb shell ln -s /system/xbin/daemonsu /system/bin/app_process
adb shell ln -s /system/xbin/daemonsu /system/bin/app_process32


ECHO. ***nstalling su...***
adb shell su --install

ECHO. ***Persisting ADB Properties...***
adb shell setprop persist.service.adb.enable 1
adb shell setprop persist.service.adb.tcp.port 5555

ECHO. ***Process Complete.***

ECHO. ****************************************
ECHO. If you get stuck at the boot logo, type 
ECHO.
ECHO. adb root
ECHO.
ECHO.       --hit enter and then type--
ECHO.
ECHO. adb shell setenforce 0
ECHO. ****************************************

ECHO. ***Rebooting device...***
adb shell reboot
pause
