cls
@echo OFF
color 0a
cls
Title Z2刷机工具箱 
Mode con cols=109 lines=30

                    :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
                    ::                                                                            ::
                    ::                            BBS.ZUK.CN                                      ::
                    ::                                                                            ::
                    :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
:START
cls
ECHO.
Echo                  ==========================================================================
ECHO.
Echo                              ZUK Z2 懒人刷机工具箱  
ECHO.
Echo                    作者: 来自Raymond98对z2p的懒人工具箱 （Kingmax8修改Z2适用）
ECHO.
Echo                    论坛：BBS.ZUK.CN(刷机有风险，请谨慎！)
ECHO.
Echo                  ==========================================================================
Echo.
Echo                                      ==== 温馨提示 ====
Echo.
Echo                                   - 请确保已经安装手机USB驱动
Echo                                   - 请确保已经在手机开启了USB调试
Echo.
PAUSE
cls
goto menu
echo.
echo.
:menu
cls
echo.
echo.
echo                                             ==================================
echo                                             =      ZUK Z2 懒人刷机工具箱     =
echo                                             ==================================
echo.
echo                                 只要输入数字 1, 2, 3, 4, 5 ...即可选择你需要的操作.
echo.
echo.
echo                                         [1]  备份用户资料
echo                                         [2]  还原用户资料
echo                                         [3]  安装手机驱动
echo                                         [4]  上锁和解锁BL
echo                                         [5]  检测手机状态
echo                                         [6]  检测Bootloader状态
echo                                         [7]  刷入第三方Recovery（TWRP）
echo                                         [8]  重启进入TWRP Recovery
echo                                         [9]  刷入官方Recovery [ZUI_2.3.042]
echo                                         [10] 刷入官方boot.img [ZUI_2.3.042]
echo                                         [11] 重启菜单
echo                                         [12] 双清/恢复出厂 [Fastboot模式下]
echo                                         [13] 手机ROOT破解
echo.                                                                          刷机有风险，请谨慎！
echo                                         [14] 进9008端口进行QFIL线刷
echo                                         [15] 进工程模式官方卡刷QSB包
echo                                         [0]  退出本窗口
echo.
echo.
PATH=%PATH%;"%SYSTEMROOT%\System32"
set /p choice= 输入数字，选择你需要的操作:
echo.
if '%choice%'=='1' goto Backup
if '%choice%'=='2' goto Restore
if '%choice%'=='3' goto DRIVER
if '%choice%'=='4' goto bootloader5
if '%choice%'=='5' goto STATUS
if '%choice%'=='6' goto statusBootloader
if '%choice%'=='7' goto TWRPRECOVERY
if '%choice%'=='8' goto BOOTTWRPRECOVERY
if '%choice%'=='9' goto STOKRECOVERY
if '%choice%'=='10' goto dpi
if '%choice%'=='11' goto reboot
if '%choice%'=='12' goto cache
if '%choice%'=='13' goto root
if '%choice%'=='14' goto 9008
if '%choice%'=='15' goto QSB
if '%choice%'=='0' goto exit-stop
goto :menu
__________________________________________________

:Backup
echo.
echo 你准备好要备份系统吗？
echo.
set /p choice= y or n ?
if '%choice%'=='y' goto :save
if '%choice%'=='n' goto :exit
goto :menu

:save
echo.
echo 备份文件将保存在工作目录!
adb backup -apk -shared -all
echo.
echo 成功!
pause
cls
goto menu

:exit
cls
goto menu

:Restore
echo.
echo 你真的需要从备份文件里面还原资料吗？
echo.
set /p choice= y or n ?
if '%choice%'=='y' goto :load
if '%choice%'=='n' goto :exit
goto :menu

:load
echo.
echo 刷机工具箱将从备份文件中还原资料!
adb restore backup.ab
echo.
echo 成功!
pause
cls
goto menu

:exit
cls
goto menu
__________________________________________________

:DRIVER
ZUK_UsbDriver_1.0.6.exe
cls
goto :menu
__________________________________________________

:bootloader5
echo.
echo      [1] 解锁第一步 写入解锁IMG
echo      [2] 解锁第二步 解锁BL
echo      [3] 上锁 Bootloader
echo      [0] 退出
echo.
set /p choice= 输入数字选择你的操作:
echo.
if '%choice%'=='1' goto :unlock1
if '%choice%'=='2' goto :unlock2
if '%choice%'=='3' goto :lock
if '%choice%'=='0' goto :exit
goto :menu

:unlock1
cls
Title Unlock Bootloader
echo.
echo.
echo.
echo.
echo.                              =================================================
echo.
echo.                                  解锁Bootloader会清空手机资料！
echo.                                  解锁第一步 把你的unlock_bootloader.img文件放到本工作目录
echo.
echo.                                              任意键继续操作...
echo.
echo.                              =================================================
pause >nul
adb reboot bootloader >nul
ping -n 5 127.0.0.1 >nul
fastboot -i 0x2b4c flash unlock unlock_bootloader.img
echo   -- 请耐心等待.....
echo.
echo                               =================================================
echo                                     Done unlocking, have fun!
echo                                     任意键返回并选择解锁第二步以完成解锁...
echo                               =================================================
pause >nul
cls
goto menu


:unlock2
cls
Title Unlock Bootloader
echo.
echo.
echo.
echo.
echo.                              =================================================
echo.
echo.                                       解锁Bootloader会清空手机资料！
echo.                                       解锁第二步 解锁
echo.
echo.                                              任意键继续操作...
echo.
echo.                              =================================================
pause >nul
adb reboot bootloader >nul
ping -n 5 127.0.0.1 >nul
fastboot -i 0x2b4c oem unlock-go
echo   -- 请耐心等待.....
echo.
echo                               =================================================
echo                                           Done unlocking, have fun!
echo                                                 任意键返回...
echo                               =================================================
pause >nul
cls
goto menu

:lock
cls
Title Lock Bootloader
echo.
echo.                              =================================================
echo.
echo.                               警告！重新锁有风险，必须官方完整资料才可以上锁。
echo.                               如果你不确定，建议使用官方ZUI1.9.077版的官方线刷包
echo.                               线刷一次可恢复原厂系统，线刷完即已上锁状态。
echo.                               任意键发送上锁指令，线刷上锁请终止...
echo.
echo.                              =================================================
pause >nul
echo.
adb reboot bootloader >nul
ping -n 5 127.0.0.1 >nul
fastboot oem lock
echo   -- 请耐心等待.....
echo.
echo.
echo.
echo                             =================================================
echo                                       Done locking Device, have fun!
echo                                              任意键返回...
echo                             =================================================
pause >nul
goto menu

:exit
cls
goto menu
__________________________________________________

:statusBootloader
cls 
echo.
echo.
echo.
echo.                            =================================================
echo.
echo.                                          正在等待手机联机:
echo.
echo                                        1- 手机是否已经开机?
echo                                        2- USB调试是否已经打开?
echo                                        3- 手机驱动是否已安装好?
echo.
echo.                                            任意键继续操作...
echo.
echo.                            =================================================
pause >nul
adb reboot bootloader >nul
ping -n 5 127.0.0.1 >nul
cls
echo.
echo.
echo.
echo.                            =================================================
echo. 
echo                                      确保你的手机已经进入Fastboot模式
echo                                             任意键继续操作...
echo.
echo.                            =================================================
pause >nul
cls
Title Status Bootloader

echo bootloader 状态:
echo.
fastboot oem device-info
echo.
echo.       =================================================
echo.
echo.       1. 如果你看到的是:
echo.         (bootloader)     Device unlocked
echo.				代表你的手机已经解锁.
echo.				
echo.       2. 如果你看到的是:
echo.         (bootloader)     Device locked  
echo.				代表你的手机有BL锁.
echo.
echo.                 任意键返回并选择重启设备!
echo.       =================================================
pause >nul
fastboot reboot
cls
goto menu
__________________________________________________

:STATUS
echo.
echo       [1] ADB
echo       [2] Fastboot
echo       [0] 退出
echo.
set /p choice= 输入数字，选择你需要的操作:
if '%choice%'=='1' goto :adb1
if '%choice%'=='2' goto :fastboot1
if '%choice%'=='0' goto :exit

:adb1
echo.
adb devices
pause >nul
cls
goto menu

:fastboot1
echo.
fastboot devices
pause >nul
cls
goto menu

:exit
cls
goto menu
__________________________________________________

:TWRPRECOVERY
echo.
echo 你需要刷入第三方Recovery吗？（刷机有风险，请谨慎操作）
echo.
set /p choice= y or n ?
if '%choice%'=='y' goto :flashtwrp
if '%choice%'=='n' goto :exit
goto :menu

:flashtwrp
echo.
adb reboot bootloader
ping -n 5 127.0.0.1 >nul
echo
echo Flashing Recovery....
echo.
fastboot flash recovery TWRP_recovery.img
ping -n 5 127.0.0.1 >nul
echo.
echo 成功刷入!
echo.
echo 现在重启进入TWRP Recovery...
fastboot boot TWRP_recovery.img
ping -n 5 127.0.0.1 >nul
pause
cls
goto menu

:exit
cls
goto menu
__________________________________________________
:BOOTTWRPRECOVERY
echo.
adb reboot bootloader
ping -n 5 127.0.0.1 >nul
echo.
echo 重启进入TWRP Recovery....
echo.
fastboot boot TWRP_recovery.img
ping -n 5 127.0.0.1 >nul
pause
cls
goto menu
__________________________________________________
:STOKRECOVERY
echo.
echo 你需要刷入官方ZUI2.3.042 Recovery吗？
echo 如需刷入其它版本，请先替换工作目录中的recovery.img文件
echo.
set /p choice= y or n ?
if '%choice%'=='y' goto :flashstock
if '%choice%'=='n' goto :exit
goto :menu

:flashstock
echo.
adb reboot bootloader
ping -n 5 127.0.0.1 >nul
echo
echo 正在刷入Recovery....
echo.
fastboot flash recovery recovery.img
ping -n 5 127.0.0.1 >nul
echo.
echo 成功刷入！
echo.
echo 重启进入官方Recovery...
fastboot boot recovery.img
ping -n 5 127.0.0.1 >nul 
pause
cls
goto menu

:exit
cls
goto menu
__________________________________________________

:Reboot
echo.
echo      [1] 重启手机
echo      [2] 重启进Recovery
echo      [3] 重启进Bootloader
echo      [0] 退出
echo.
set /p choice= 输入数字选择你需要的操作:
echo.
if '%choice%'=='1' goto :Normal
if '%choice%'=='2' goto :Recovery
if '%choice%'=='3' goto :Bootloader
if '%choice%'=='4' goto :Exit
goto :menu

:Normal
echo.
adb reboot
cls
goto menu

:Recovery
echo.
adb reboot recovery
cls
goto menu

:Bootloader
echo.
adb reboot bootloader
cls
goto menu

:exit
cls
goto menu
_____________________________________________________

:cache
echo.
echo 你真的需要双清手机吗？
echo.
set /p choice= y or n ?
echo.

if '%choice%'=='y' goto :wipecache
if '%choice%'=='n' goto :exit
goto :menu

:wipecache
echo.
fastboot reboot bootloader
ping -n 5 127.0.0.1 >nul
fastboot format cache
echo.
echo Done!
echo.
echo 任意键退出...
pause >nul
cls
goto menu

:exit
cls
goto menu
______________________________________________________

:dpi
echo.
echo 你需要刷入官方ZUI2.3.042 boot.img吗？
echo 如需刷入其它版本，请先替换工作目录中的boot.img文件
echo.
set /p choice= y or n ?
if '%choice%'=='y' goto :flashstock2
if '%choice%'=='n' goto :exit
goto :menu

:flashstock2
echo.
adb reboot bootloader
ping -n 5 127.0.0.1 >nul
echo
echo 正在刷入boot.img....
echo.
fastboot flash boot boot.img
ping -n 5 127.0.0.1 >nul
echo.
echo 成功刷入！
echo.
pause
cls
goto menu

:exit
cls
goto menu
______________________________________________________
:root
cls
Title Push SuperSU in device
echo.
echo.
echo.
echo.
echo                            ========================================================
echo.
echo                                     本操作只是推送ROOT补丁包到手机内置存储卡
echo                                                  任意键继续...
echo.
echo                            ========================================================
pause >nul
adb push SuperSU-beta.zip /sdcard/
echo.
echo Done!
cls
Title Push SuperSU in device
echo.
echo.
echo.
echo.
echo.                         ==============================================================
echo.
echo.                          重启进入TWRP Recovery, 然后手动安装ROOT补丁包
echo.
echo.                          其实Z2的TWRP Recovery已自带ROOT破解功能，
echo.                          每次在TWRP Recovery里重启系统都会有提示，滑动即可对Z2手机ROOT权限
echo.
echo.                          任意键进入TWRP Recovery...
echo.
echo.                         ==============================================================
echo.
echo.
adb reboot bootloader
ping -n 5 127.0.0.1 >nul

fastboot boot TWRP_recovery.img
ping -n 5 127.0.0.1 >nul
pause >nul
cls
goto :menu
______________________________________________________

:9008
echo.
adb reboot edl
cls
goto menu
______________________________________________________

:QSB
echo.
echo ZUK官方recovery才可在工程模式进行官方QSB包卡刷
pause
adb reboot testmode
cls
goto menu
______________________________________________________

:exit-stop
echo 任意键退出本工具...
pause >nul
cls
exit