@ECHO OFF
cd /D "%~dp0"
SET awVER=1.3 beta 2
SET awPATH=%PATH%
SET PATH=%PATH%;lib
IF NOT EXIST ROM MD ROM
IF NOT EXIST SplashBMP MD SplashBMP
ECHO ============== aWizard %awVer% ===============
ECHO -              By ahlok_hk               -
ECHO __________________________________________
ECHO - [Credits]                              -
ECHO - itsme      for 'itsutils'              -
ECHO - MachinaGod for 'RapiUnlocker'          -
ECHO - MachinaGod for 'lokiwiz'               -
ECHO - mamaich    for 'WM5 ROM editing tool'  -
ECHO - psneddon and kenu for Logo Converter   -
ECHO - nicob for scripting tips               -
ECHO - xda-developers.com, buzzdev.net n oths -
ECHO - 一个叫kuangtian的小孩汉化              -
GOTO awChoice

:awChoice
ECHO __________________________________________
ECHO.
ECHO * 请选择一个下列选项:
ECHO.
ECHO a - 察看说明文档
ECHO e - 开启 RAPI   (每次硬启动必须运行一次)
ECHO u - 解锁 CID   (!!!必须在运行此选项至少一次!!!)
ECHO b - 从设备备份无线,操作系统及Extended ROM
ECHO s - 向Wizard刷写备份的启动屏幕
ECHO c - 转换并刷写 BMP(240x320) 文件到Wizard启动屏幕
ECHO r - 向设备刷写无线ROM   (!! 首先运行"解锁CID" !!)
ECHO w - 向设备刷写操作系统ROM   (!! 首先运行"解锁CID" !!)
ECHO q - 离开此程序
ECHO __________________________________________
ECHO !!! 注意!!!风险自担!!!!
ECHO __________________________________________
SET Choice=
Set /P Choice=* 输入代码并按回车:
IF NOT '%Choice%'=='' SET Choice=%Choice:~0,1%
IF /I '%Choice%'=='a' GOTO awReadme
IF /I '%Choice%'=='u' GOTO awUnlock
IF /I '%Choice%'=='b' GOTO awBackup
IF /I '%Choice%'=='e' GOTO awEnable
IF /I '%Choice%'=='r' GOTO awRadio
IF /I '%Choice%'=='w' GOTO awWrite
IF /I '%Choice%'=='s' GOTO awSplash
IF /I '%Choice%'=='c' GOTO awConvert
IF /I '%Choice%'=='q' GOTO awQuit
GOTO awChoice

:awUnlock
ECHO * 请使用ActiveSync连接您的Wizard, 
SET Choice07=
Set /P Choice07=* 然后按 [Enter] 开始, 或Q退回主菜单:
IF /I '%Choice07%'=='q' GOTO awChoice
@set /P dummy="Initializing"<NUL 
lib\cecopy lib\EnableRapi.cab dev:\ >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
lib\cecopy lib\Cert_SPCS.cab dev:\ >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
lib\cerun.exe -b CE:\Windows\wceload.exe \Cert_SPCS.cab /noui >NUL
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
lib\cerun.exe -b CE:\Windows\wceload.exe \EnableRapi.cab /noui >NUL
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
ECHO 正在解锁CID...切勿断开连接直到设备自动重启！
CALL :awLog MachinaGod lokiwiz start
lib\pdocread.exe -n 1 0x000000 0x10000 -b 0x4000 lock_backup.bin
lib\wizardunlock.exe lock_backup.bin -c 11111111 -w cidunlocked.bin
lib\pdocwrite.exe -n 1 -b 0x4000 cidunlocked.bin 0x000000 0x010000
lib\preboot.exe

CALL :awLog 您的设备已经CID解锁....
ECHO 保存产生的'lock_backup.bin'文件到一个安全之处.当有任何错误产生时，它可以帮助您恢复您的系统.
Set Choice99=''
Set /P Choice99=* 按 [Enter] 继续
GOTO awChoice

:awEnable
ECHO * 请完全将设备通过ActiveSync同步,
SET Choice01=
Set /P Choice01=* 然后按回车开始, 或q回到主菜单:
IF /I '%Choice01%'=='q' GOTO awChoice
ECHO MachinaGod RapiUnlocker v1.0
@set /P dummy="Initializing"<NUL 
lib\cecopy lib\EnableRapi.cab dev:\ >NUL
@set /P dummy="."<NUL 
lib\cecopy lib\Cert_SPCS.cab dev:\ >NUL
@set /P dummy="."<NUL 
lib\cerun.exe -b CE:\Windows\wceload.exe \Cert_SPCS.cab /noui >NUL
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
lib\cerun.exe -b CE:\Windows\wceload.exe \EnableRapi.cab /noui >NUL
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
ECHO Done!
Set Choice99=''
Set /P Choice99=* Press [Enter] to continue
GOTO awChoice

:awBackup
REM ================================ awBackup =======================================
ECHO * Backup Wizard ROM Version 1.0
SET Choice02=
ECHO * 请输入将ROM镜像保存到何目录(例如 "QT-1_6_3_4-WWE"), 请勿加空格
Set /P Choice02=* 然后按回车开始，或Q回到主菜单:
IF /I '%Choice02%'=='' (
  ECHO ! Error: No Input.
  GOTO awChoice
) ELSE (
  IF /I '%Choice02%'=='q' GOTO awChoice
)
SET Choice11=
SET Choice12=
SET Choice13=
SET Choice14=
SET /P Choice11=* Backup Radio ROM? (y/n/q):
IF '%Choice11%'=='' GOTO awChoice ELSE SET Choice11=%Choice11:~0,1%
IF /I '%Choice11%'=='q' GOTO awChoice
ECHO.
SET /P Choice12=* Backup OS ROM? (y/n/q):
IF '%Choice12%'=='' GOTO awChoice ELSE SET Choice12=%Choice12:~0,1%
IF /I '%Choice12%'=='q' GOTO awChoice
ECHO.
SET /P Choice13=* Backup Extended ROM? (y/n/q):
IF '%Choice13%'=='' GOTO awChoice ELSE SET Choice13=%Choice13:~0,1%
IF /I '%Choice13%'=='q' GOTO awChoice
ECHO.
SET /P Choice14=* Backup Splash ROM and HTC Logo? (y/n/q):
IF '%Choice14%'=='' GOTO awChoice ELSE SET Choice14=%Choice14:~0,1%
IF /I '%Choice14%'=='q' GOTO awChoice
SET Choice03=
ECHO.
ECHO * 运行此选项前，请务必确认下列事项:
ECHO * - 您的设备已经与ActiveSync通过USB连接,
ECHO * - 在您上一次硬启动后运行过"E"选项（开启 RAPI）
ECHO.
SET /P Choice03=* 然后按回车开始，或Q回到主菜单:
IF /I '%Choice03%'=='q' GOTO awChoice
IF NOT EXIST ROM\%Choice02% (
  MKDIR ROM\%Choice02%
)
SET awSkipRadio=0
SET awSkipOS=0
SET awSkipExt=0
SET awSkipSplash=0
IF /I '%Choice11%'=='y' (
  CALL :awLog Backup Radio ROM [ROM\%Choice02%\%Choice02%-Radio.nba] Start
  IF EXIST ROM\%Choice02%\%Choice02%-Radio.nba (
    SET Choice16=
    SET /P Choice16=* [ROM\%Choice02%\%Choice02%-Radio.nba] already exist. Replace it? y/n
    IF NOT '%Choice16%'=='' SET Choice16=%Choice16:~0,1%
echo 16:%Choice16%
    IF NOT '%Choice16%'=='y' SET awSkipRadio=1
  )
  IF /I '%awSkipRadio%'=='0' (
    ECHO * 根据CPU不同，此过程可能需要5至8分钟. 
    ECHO * 请稍候.....
    lib\pdocread.exe -n 1 0x50000 0x280000 ROM\%Choice02%\%Choice02%-Radio.nba
    CALL :awLog Backup Radio ROM [ROM\%Choice02%\%Choice02%-Radio.nba] End
    ECHO.
  )
)
IF /I '%Choice12%'=='y' (
  CALL :awLog Backup OS ROM [ROM\%Choice02%\%Choice02%-OS.nba] Start
  IF EXIST ROM\%Choice02%\%Choice02%.nba (
    SET Choice16=
    SET /P Choice16=* [ROM\%Choice02%\%Choice02%-OS.nba] already exist. Replace it? y/n
    IF NOT '%Choice16%'=='' SET Choice16=%Choice16:~0,1%
    IF NOT '%Choice16%'=='y' SET awSkipOS=1
  )
  IF /I '%awSkipOS%'=='0' (
    ECHO * 根据CPU不同，此过程可能需要12至15分钟.
    ECHO * 请稍候.....
    lib\pdocread.exe 0 0x3900000 ROM\%Choice02%\%Choice02%-OS.nba
    lib\pget \windows\boot.rgu ROM\%Choice02%
    CALL :awLog Backup OS ROM [ROM\%Choice02%\%Choice02%-OS.nba] End
    ECHO.
  )
)
IF /I '%Choice13%'=='y' (
  CALL :awLog Backup Extended ROM to [ROM\%Choice02%\%Choice02%-ExtROM] Start
  IF EXIST ROM\%Choice02%\%Choice02%-ExtROM (
    SET Choice16=
    SET /P Choice16=* [ROM\%Choice02%\%Choice02%-ExtROM] already exist. Replace it? y/n
    IF NOT '%Choice16%'=='' SET Choice16=%Choice16:~0,1%
    IF NOT '%Choice16%'=='y' (
      SET awSkipExt=1
    ) ELSE (
      DEL /F /Q ROM\%Choice02%\%Choice02%-ExtROM\*.*
    )
  ) ELSE (
    MKDIR ROM\%Choice02%\%Choice02%-ExtROM
  )
  IF /I '%awSkipExt%'=='0' (
    lib\pget \extended_rom\*.* ROM\%Choice02%\%Choice02%-ExtROM
    CALL :awLog Backup Extended ROM to [ROM\%Choice02%\%Choice02%-ExtROM] End
  )
)
IF /I '%Choice14%'=='y' (
  CALL :awLog Backup Splash ROM [ROM\%Choice02%\%Choice02%-Splash.nba] Start
  IF EXIST ROM\%Choice02%\%Choice02%-Splash.nba (
    SET Choice16=
    SET /P Choice16=* [ROM\%Choice02%\%Choice02%-Splash.nba] already exist. Replace it? y/n
    IF NOT '%Choice16%'=='' SET Choice16=%Choice16:~0,1%
echo 16:%Choice16%
    IF NOT '%Choice16%'=='y' SET awSkipSplash=1
  )
  IF EXIST ROM\%Choice02%\%Choice02%-HTCLogo.nba (
    SET Choice16=
    SET /P Choice16=* [ROM\%Choice02%\%Choice02%-HTCLogo.nba] already exist. Replace it? y/n
    IF NOT '%Choice16%'=='' SET Choice16=%Choice16:~0,1%
echo 16:%Choice16%
    IF NOT '%Choice16%'=='y' SET awSkipSplash=1
  )
  IF /I '%awSkipSplash%'=='0' (
    ECHO.
    ECHO * This process takes about 3 to 6 minutes depends on CPU Speed
    ECHO * Please wait.....
    lib\pdocread.exe -n 1 0x2D0000 0x30000 ROM\%Choice02%\%Choice02%-Splash.nba
    CALL :awLog Backup Splash ROM [ROM\%Choice02%\%Choice02%-Splash.nba] End
    CALL :awLog Backup Splash ROM [ROM\%Choice02%\%Choice02%-HTCLogo.nba] Start
    lib\pdocread.exe -n 1 0x30000 0x10000 ROM\%Choice02%\%Choice02%-HTCLogo.nba
    CALL :awLog Backup Splash ROM [ROM\%Choice02%\%Choice02%-HTCLogo.nba] End
    ECHO.
  )
)
PAUSE
GOTO awChoice

:awWrite
REM ================================ awWrite =======================================
ECHO.
ECHO * Write Wizard OS ROM Version 0.3
ECHO.
CD ROM
FOR /F "usebackq delims=" %%i IN (`cd`) DO SET awCURDIR=%%i
ECHO * 在 [%awCURDIR%] 中查找ROM文件. 请稍候...
ECHO.
ECHO ------ 可用的 OS ROM 文件 ------
SET awCount=1
FOR /F "usebackq delims=" %%j IN (`DIR /s /b *.nba`) DO CALL :getRPath 59768832 %%j
ECHO ------------我是分隔符^O^----------------------
ECHO.
ECHO * 请选择 OS ROM 镜像文件刷写到设备 (输入编号),
SET Choice04=
Set /P Choice04=* 然后按回车开始，或Q回到主菜单:
CD ..
IF /I '%Choice04%'=='' (
  ECHO ! Error: No Input.
  GOTO awChoice
) ELSE (
  IF /I '%Choice04%'=='q' GOTO awChoice
)
SET awCount=1
SET awCCC=
CD ROM
FOR /F "usebackq delims=" %%j IN (`DIR /s /b *.nba`) DO CALL :getChoice 59768832 %%j
CD ..
SET Choice04=%awCCC%
FOR /F %%f IN ("%Choice04%") DO SET awFilename=%%~nxf
IF NOT EXIST %Choice04% (
  ECHO *
  ECHO !警告: 文件 [%awFilename%] 不存在!
  GOTO awChoice
)
SET SIZE=0
FOR /F "tokens=3* delims= " %%A IN ('DIR %Choice04% /-C /W ^| FIND /I "59768832"') do SET SIZE=%%A
IF /I '%SIZE%'=='59768832' (
  ECHO *
) ELSE (
  ECHO *
  ECHO !警告: 文件 [%awFilename%] 大小无效!
  GOTO awChoice
)
ECHO.
ECHO * !!! 请确保你已经:
ECHO * 1- 使用此项目前硬启或至少软启过系统
ECHO * 2- 已使用ActiveSync连接设备与计算机,
ECHO * 3- 运行过选项 'e' 启用 RAPI, 
ECHO * 4- 运行过选项 'u' 解锁了 CID, 
ECHO.
SET Choice05=''
Set /P Choice05=* 然后按回车开始，或Q回到主菜单:
IF /I '%Choice05%'=='' (
  ECHO ! Error: No Input.
  GOTO awChoice
) ELSE (
  IF /I '%Choice05%'=='q' GOTO awChoice
)
ECHO.
CALL :awLog Write ROM [%awFilename%] Start
ECHO.
ECHO Do not disconnect the Wizard during the process
@set /P dummy="Initializing"<NUL 
lib\cecopy lib\EnableRapi.cab dev:\ >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
lib\cecopy lib\Cert_SPCS.cab dev:\ >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
lib\cerun.exe -b CE:\Windows\wceload.exe \Cert_SPCS.cab /noui >NUL
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
lib\cerun.exe -b CE:\Windows\wceload.exe \EnableRapi.cab /noui >NUL
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
PING 1.1.1.1 -n 1 -w 4000 >NUL
@set /P dummy="."<NUL 
ECHO CID unlocking mobile... 
CALL :awLog MachinaGod lokiwiz start
lib\pdocread.exe -n 1 0x000000 0x10000 -b 0x4000 alock_backup.bin
lib\wizardunlock.exe alock_backup.bin -c 11111111 -w acidunlocked.bin
lib\pdocwrite.exe -n 1 -b 0x4000 acidunlocked.bin 0x000000 0x010000
ECHO.
ECHO * 根据CPU不同，此过程可能需要12到20分钟
ECHO * 请稍候...
lib\pdocwrite.exe %Choice04% 0 0x3900000
CALL :awLog Write ROM [%awFilename%] End
ECHO.
ECHO.
SET Choice97=''
ECHO ! 如果您遇到 itsutils 错误 ，切勿硬启动(!)，尝试以下步骤：
ECHO ---1. 断开USB连接，并重连
ECHO ---2. 等待直到ActiveSync完全连接完毕
ECHO ---3. 运行选项 'e'
ECHO ---4. 运行选项 'u'
ECHO ---5. 再次运行选项 'w'
ECHO.
ECHO ! 如果您的设备停留在启动画面超过5分钟，请参阅FAQ
ECHO.
ECHO * 如果没有错误提示，请硬启动设备
ECHO * 1 - 按住 "Voice Dial" + "Wireless Manager" 并戳下 "reset" 
ECHO * 2 - 按住前两个键直到你看到屏幕提示你按绿色电话键来硬启动
ECHO * 3 - 按绿色拨号键硬启动
ECHO * # 假如你想跳过Extended_ROM的安装，在系统倒计时时，戳Reset软启即可。
ECHO.

Set /P Choice97=* 按回车继续...
GOTO awChoice

:awRadio
REM ================================ awRadio =======================================
ECHO * Write Wizard Radio ROM Version 0.2
ECHO.
CD ROM
FOR /F "usebackq delims=" %%i IN (`cd`) DO SET awCURDIR=%%i
ECHO * 在 [%awCURDIR%]中查找Radio ROM. 请稍候...
ECHO.
ECHO --------- 可用的Radio Rom ---------
SET awCount=1
FOR /F "usebackq delims=" %%j IN (`DIR /s /b *-Radio.nba`) DO CALL :getRPath 2621440 %%j
ECHO ------------------我是分隔符^O^----------------------------
SET Choice04=
ECHO.
ECHO * 请选择 Radio ROM 镜像文件刷写到设备, 
Set /P Choice04=* 请输入编号并按回车继续，或者按Q回到主菜单:
CD ..
IF /I '%Choice04%'=='' (
  ECHO ! Error: No Input.
  GOTO awChoice
) ELSE (
  IF /I '%Choice04%'=='q' GOTO awChoice
)
SET awCount=1
SET awCCC=
CD ROM
FOR /F "usebackq delims=" %%j IN (`DIR /s /b *-Radio.nba`) DO CALL :getChoice 2621440 %%j
CD ..
SET Choice04=%awCCC%
FOR /F %%f IN ("%Choice04%") DO SET awFilename=%%~nxf
IF NOT EXIST %Choice04% (
  ECHO *
  ECHO !警告:  文件 [%Choice04%] 不存在!
  GOTO awChoice
)
SET SIZE=0
FOR /F "tokens=3* delims= " %%A IN ('DIR %Choice04% /-C /W ^| FIND /I "2621440"') do SET SIZE=%%A
IF /I '%SIZE%'=='2621440' (
  ECHO *
) ELSE (
  ECHO *
  ECHO !警告:  文件 [%awFilename%] 大小无效!
  GOTO awChoice
)
ECHO * !!! 请确保你已经:
ECHO.
ECHO * 1- 运行过选项 'e' 启用 RAPI, 
ECHO * 2- 运行过选项 'u' 解锁了 CID,  
ECHO * 已使用ActiveSync连接设备与计算机,
ECHO.
SET Choice05=''
Set /P Choice05=* 然后按回车开始，或Q回到主菜单:
IF /I '%Choice05%'=='' (
  ECHO ! Error: No Input.
  GOTO awChoice
) ELSE (
  IF /I '%Choice05%'=='q' GOTO awChoice
)
CALL :awLog Write Radio ROM [%awFilename%] Start
ECHO.
ECHO 过程中切勿断开连接...
ECHO * 此过程可能会需要10至16分钟.
ECHO * 请稍候.....
lib\pdocwrite.exe %Choice04% -n 1 0x50000 0x280000
CALL :awLog Write Radio ROM [%awFilename%] End
SET Choice97=''
ECHO * 如果没有错误，请软启，否则请断开连接，连接后重试.
ECHO.
Set /P Choice97=* 您想现在重新启动设备吗？ (y/n) 
IF /I '%Choice97%'=='' (
  ECHO ! Error: No Input.
  GOTO awChoice
) ELSE (
  IF /I '%Choice97%'=='y' (
    lib\preboot.exe
  ) ELSE (
    GOTO awChoice
  )
)
GOTO awChoice

:awConvert
REM ================================ awConvert =======================================
ECHO * Wizard Logo Convert Version 0.1
ECHO.
ECHO * 此选项转换您自己的BMP文件并直接刷写至设备, 请准备一张240（宽）*320（高）的24位BMP文件，并将其放置于SplashBMP文件夹中
ECHO.
CD SplashBMP
FOR /F "usebackq delims=" %%i IN (`cd`) DO SET awCURDIR=%%i
ECHO * 在 [%awCURDIR%]中查找文件. 请稍候...
ECHO.
ECHO ------ 可用的 BMP ROM 文件 ------
SET awCount=1
FOR /F "usebackq delims=" %%j IN (`DIR /s /b *.bmp`) DO CALL :getRPath 230454 %%j
ECHO ----------------------------------
ECHO.
ECHO * 请输入所要刷写的BMP图片文件名
SET Choice04=
Set /P Choice04= * 然后按回车继续，或Q退回主菜单:
CD ..
IF /I '%Choice04%'=='' (
  ECHO ! Error: No Input.
  GOTO awChoice
) ELSE (
  IF /I '%Choice04%'=='q' GOTO awChoice
)
SET awCount=1
SET awCCC=
CD SplashBMP
FOR /F "usebackq delims=" %%j IN (`DIR /s /b *.bmp`) DO CALL :getChoice 230454 %%j
CD ..
SET Choice04=%awCCC%
FOR /F %%f IN ("%Choice04%") DO SET awFilename=%%~nxf

IF NOT EXIST %Choice04% (
  ECHO *
  ECHO !Warning: 文件 [%awFilename%] 不存在!
  GOTO awChoice
)
SET SIZE=0
FOR /F "tokens=3* delims= " %%A IN ('DIR %Choice04% /-C /W ^| FIND /I "230454"') do SET SIZE=%%A
IF /I '%SIZE%'=='230454' (
  ECHO *
) ELSE (
  ECHO *
  ECHO !Warning: 文件 [%awFilename%] 大小无效!
  GOTO awChoice
)

ECHO ---------------Convert BMP-----------------
SET Choice03=
ECHO.
ECHO * 请确保你已经:
ECHO * - 已使用ActiveSync连接设备与计算机,
ECHO * - 最近一次硬启动后，运行过选项 'e' 启用 RAPI
ECHO.
SET /P Choice03=* then press [Enter] to start, or q to main menu:
IF /I '%Choice03%'=='q' GOTO awChoice
IF EXIST SplashBMP\splash-temp.bin DEL SplashBMP\splash-temp.bin
lib\logoConvert.exe bmp2bin %Choice04% SplashBMP\splash-temp.bin
ECHO ----------刷写转换后的图片------------
lib\pdocwrite.exe -n 1 SplashBMP\splash-temp.bin 0x2D0000
ECHO ------------------完成---------------------
IF EXIST SplashBMP\splash-temp.bin DEL SplashBMP\splash-temp.bin
ECHO.
ECHO * 如果没有错误，请软启，否则请断开连接，连接后重试.
ECHO.
Set /P Choice97=* 您想现在重新启动设备吗? (y/n) 
IF /I '%Choice97%'=='' (
  ECHO ! Error: No Input.
  GOTO awChoice
) ELSE (
  IF /I '%Choice97%'=='y' (
    lib\preboot.exe
  ) ELSE (
    GOTO awChoice
  )
)
GOTO awChoice

:awSplash
REM ================================ awSplash =======================================
ECHO.
ECHO * Wizard Splash Restore Version 0.1
ECHO.
CD ROM
FOR /F "usebackq delims=" %%i IN (`cd`) DO SET awCURDIR=%%i
ECHO * 在 [%awCURDIR%]中查找备份的启动画面. 请稍候...
ECHO.
ECHO ----- 可用的启动画面文件 -----
SET awCount=1
FOR /F "usebackq delims=" %%j IN (`DIR /s /b *.nba`) DO CALL :getRPath 196608 %%j
ECHO ----------------------------------
ECHO.
ECHO * 刷写启动画面ROM到设备,
ECHO * 请输入启动ROM前的编号以选择刷写至设备,
SET Choice04=
Set /P Choice04= * 按回车继续, 或q退回主菜单:
CD ..
IF /I '%Choice04%'=='' (
  ECHO ! 错误：无输入.
  GOTO awChoice
) ELSE (
  IF /I '%Choice04%'=='q' GOTO awChoice
)
SET awCount=1
SET awCCC=
CD ROM
FOR /F "usebackq delims=" %%j IN (`DIR /s /b *.nba`) DO CALL :getChoice 196608 %%j
CD ..
SET Choice04=%awCCC%
FOR /F %%f IN ("%Choice04%") DO SET awFilename=%%~nxf

IF NOT EXIST %Choice04% (
  ECHO *
  ECHO !警告:文件 [%awFilename%] 不存在!
  GOTO awChoice
)
SET SIZE=0
FOR /F "tokens=3* delims= " %%A IN ('DIR %Choice04% /-C /W ^| FIND /I "196608"') do SET SIZE=%%A
IF /I '%SIZE%'=='196608' (
  ECHO *
) ELSE (
  ECHO *
  ECHO !警告:文件 [%awFilename%] 大小无效!
  GOTO awChoice
)

SET Choice03=
ECHO.
ECHO * 请确保你已经::
ECHO * - 已使用ActiveSync连接设备与计算机,
ECHO * - 最近一次硬启动后，运行过选项 'e' 启用 RAPI
ECHO.
SET /P Choice03=* 按回车继续, 或q退回主菜单:
IF /I '%Choice03%'=='q' GOTO awChoice
ECHO ------------刷写启动画面ROM中--------------
lib\pdocwrite.exe -n 1 %Choice04% 0x2D0000
ECHO ------------------完成---------------------
ECHO.
ECHO * 如果没有错误，请软启，否则请断开连接，连接后重试.
ECHO.
Set /P Choice97=* 您想现在重新启动设备吗? (y/n) 
IF /I '%Choice97%'=='' (
  ECHO ! Error: No Input.
  GOTO awChoice
) ELSE (
  IF /I '%Choice97%'=='y' (
    lib\preboot.exe
  ) ELSE (
    GOTO awChoice
  )
)
GOTO awChoice

:awReadme
REM ================================ awReadme =======================================
TYPE README.txt|MORE
PAUSE
GOTO awChoice

:getRPath
FOR /F "usebackq" %%F IN (`@ECHO %2`) DO SET SIZE=%%~zF
IF /I '%SIZE%'=='%1' (
  SET /A awCount=awCount + 1
  SET awTarget=%2
  CALL ECHO %awCount% - %%awTarget:%awCURDIR%\=%%
)
GOTO:EOF

:getChoice
FOR /F "usebackq" %%F IN (`@ECHO %2`) DO SET SIZE=%%~zF
IF /I '%SIZE%'=='%1' (
  SET /A awCount=awCount + 1
  If "%Choice04%" == "%awCount%" Set awCCC=%2
)
GOTO:EOF

:awLog
SET awMessage=%*
ECHO [%time%] %awMessage%
GOTO:EOF

:awQuit
REM ================================ awQuit =======================================
SET Choice98=''
Set /P Choice98=* 您确认要退出吗? (y/n) 
IF /I '%Choice98%'=='y' (
  SET PATH=%awPATH%
  ECHO ======= Enjoy your Wizard!! =======
) ELSE (
  GOTO awChoice
)
