关闭

魅族 M9 的刷机脚本代码

1353人阅读 评论(0) 收藏 举报
@echo off
Setlocal EnableDelayedExpansion
adb kill-server>nul
taskkill /f /im adb.exe>nul 2>nul
taskkill /f /im tadb.exe>nul 2>nul
taskkill /f /fi "imagename eq wandoujia*">nul 2>nul
taskkill /f /im AndroidInterface.exe>nul 2>nul
taskkill /f /im "Android PC Suite.exe">nul 2>nul
netstat -p TCP -n -o | findstr ":5037" > port
for /f "tokens=5 delims= " %%a in (port) do taskkill /F /PID %%a>nul 2>nul
del /s /f /q port>nul 2>nul
title USB Dbg Connecting...
adb wait-for-device > nul
adb devices | findstr /B "M9"
if %errorlevel%==0 goto :foundM9
echo ERROR:未检测到M9,请确认接入的android设备是魅族M9,按任意键退出
pause > nul
exit

:foundM9
del /s /f /q device>nul 2>nul
title USB Dbg Connected
echo.
adb shell mv /data/local/tmp /data/local/tmp.bak
adb shell ln -s /data /data/local/tmp
cls
echo INFO:开始刷机
echo.
adb reboot
echo INFO:正在重启手机(第1次,共3次),请在重启进桌面后确认USB调试打开后按任意键继续
echo.
title USB Dbg Connecting...
pause > nul
adb wait-for-device > nul
title USB Dbg Connected
adb shell rm /data/local.prop > nul
adb shell "echo \"ro.kernel.qemu=1\" > /data/local.prop"
adb reboot
echo INFO:正在重启手机(第2次,共3次),请在重启进桌面后确认USB调试打开后按任意键继续
echo.
title USB Dbg Connecting...
pause > nul
adb wait-for-device > nul
title USB Dbg Connected
netstat -p TCP -n -o | findstr ":5037" > port
for /f "tokens=5 delims= " %%a in (port) do taskkill /F /PID %%a>nul 2>nul
del /s /f /q port>nul 2>nul
echo.
adb shell id | findstr /I "uid=0(root) gid=0(root)"
if %errorlevel%==1 goto end1

adb remount > nul

adb shell rm /data/local.prop
adb shell rm /data/local/tmp
adb shell mv /data/local/tmp.bak /data/local/tmp

adb push su /system/bin/su>nul 2>nul
if %errorlevel%==1 call :pushfailed "/system/bin/su"
echo INFO:成功上传/system/bin/su
adb shell chmod 06755 /system/bin/su

adb push busybox /data/local/busybox>nul 2>nul
if %errorlevel%==1 call :pushfailed "/data/local/busybox"
echo INFO:成功上传/data/local/busybox
adb shell chmod 0755 /data/local/busybox

set busybox="/data/local/busybox"
adb shell %busybox% mount -o remount,rw,noatime /
adb shell %busybox% mount -o remount,rw,noatime /system

adb wait-for-device > nul
rem adb shell %busybox% rm -f /system/app/ApplicationsProvider.*
adb shell %busybox% rm -f /system/app/BackupRestoreConfirmation.*
adb shell %busybox% rm -f /system/app/Calculator.*
rem adb shell %busybox% rm -f /system/app/CalendarProvider.*
rem adb shell %busybox% rm -f /system/app/Calendar.*
adb shell %busybox% rm -f /system/app/CertInstaller.*
adb shell %busybox% rm -f /system/app/DLNAServer.*
adb shell %busybox% rm -f /system/app/DownloadProviderUi.*
adb shell %busybox% rm -f /system/app/DrmProvider.*
adb shell %busybox% rm -f /system/app/Email.*
adb shell %busybox% rm -f /system/app/Exchange.*
rem adb shell %busybox% rm -f /system/app/FileManager.*
adb shell %busybox% rm -f /system/app/GoogleCalendarSyncAdapter.*
adb shell %busybox% rm -f /system/app/GoogleContactsSyncAdapter.*
adb shell %busybox% rm -f /system/app/GoogleLoginService.*
adb shell %busybox% rm -f /system/app/GoogleServicesFramework.*
adb shell %busybox% rm -f /system/app/HTMLViewer.*
adb shell %busybox% rm -f /system/app/KeyChain.*
adb shell %busybox% rm -f /system/app/LiveWallpapersPicker.*
rem adb shell %busybox% rm -f /system/app/MusicFX.*
rem adb shell %busybox% rm -f /system/app/Mstore.*
rem adb shell %busybox% rm -f /system/app/Mtheme.*
rem adb shell %busybox% rm -f /system/app/MzAccount.*
adb shell %busybox% rm -f /system/app/MzAutoInstaller.*
rem adb shell %busybox% rm -f /system/app/MzCloudService.*
rem adb shell %busybox% rm -f /system/app/MzPhoneLocationService.*
adb shell %busybox% rm -f /system/app/MzSimContacts.*
rem adb shell %busybox% rm -f /system/app/MzSyncService.*
adb shell %busybox% rm -f /system/app/NetworkLocation.*
rem adb shell %busybox% rm -f /system/app/NotePaper.*
adb shell %busybox% rm -f /system/app/PackageInstaller.odex
adb shell %busybox% rm -f /system/app/PicoTts.*
adb shell %busybox% rm -f /system/app/QuickSearchBox.*
adb shell %busybox% rm -f /system/app/SharedStorageBackup.*
adb shell %busybox% rm -f /system/app/Stk.*
rem adb shell %busybox% rm -f /system/app/SystemUI.*
adb shell %busybox% rm -f /system/app/Unzip.*
adb shell %busybox% rm -f /system/app/UserDictionaryProvider.*
adb shell %busybox% rm -f /system/app/Vending.*
adb shell %busybox% rm -f /system/app/VoiceDialer.*
adb shell %busybox% rm -f /system/app/科学上网Dialogs.*
adb shell %busybox% rm -f /system/app/WAPPushManager.*
adb shell %busybox% rm -f /system/app/WapiSetting.*
adb shell %busybox% rm -r /system/tts
adb shell %busybox% rm -r /system/media/audio/alarms
adb shell %busybox% rm -r /system/media/audio/notifications
adb shell %busybox% rm -r /system/media/audio/ringtones
adb shell %busybox% rm -f /system/lib/libtts*

echo.
echo INFO:开始上传ROM
for /r system %%i in (*) do (
        title USB Dbg Connecting...
        adb wait-for-device > nul
        title Uploading %%i
        call :loop "%%i"
)

for /r data %%i in (*) do (
        title USB Dbg Connecting...
        adb wait-for-device > nul
        title Uploading %%i
        call :loop "%%i"
)
echo INFO:成功上传ROM

adb shell /system/bin/busybox --install /system/bin

adb shell rm /data/local/busybox
ping 127.0.0.1 -n 3 > nul
adb reboot
adb kill-server
taskkill /f /im adb.exe>nul 2>nul
echo.
echo INFO:正在重启手机(第3次,共3次) - 刷机成功,按任意键退出
pause > nul
exit

:end1
adb shell mv /data/local/tmp.bak /data/local/tmp
adb reboot
adb kill-server
taskkill /f /im adb.exe>nul 2>nul
echo.
echo ERROR:正在重启手机(刷机失败,无法获取ROOT权限)- 请等待重启完毕之后重试
pause > nul
exit

:end2
adb shell mv /data/local/tmp.bak /data/local/tmp
adb kill-server
taskkill /f /im adb.exe>nul 2>nul
echo.
echo ERROR:文件上传失败,请清除数据重刷官方Flyme1.1.3后再试
pause > nul
exit

:pushfailed
echo ERROR:文件%1上传失败,是否继续刷机?按Y继续,其他键退出刷机
set choice=
set /p choice=输入您的选择:
if /i "%choice%"=="Y" goto :eof
goto :end2

:loop
set dir=%~dp1
set "dir=!dir:%~dp0%=!"
set "dir=/!dir:\=/!"
set file=%dir%%~nx1
if "%dir%"=="/system/bin/" goto :0755
if "%dir%"=="/system/xbin/" goto :0755
adb shell -c "ls %dir%>nul && echo $?" | findstr /B "0"
if %errorlevel%==0 goto :foundDir
adb shell mkdir "%dir%">nul 2>nul
adb shell chmod 0755 "%dir%"
:foundDir
if "%~x1"==".sh" goto :0755
adb push %1 "%file%">nul 2>nul
if %errorlevel%==1 call :pushfailed "%file%"
echo INFO:成功上传%file%
adb shell chmod 0644 "%file%">nul 2>nul
goto :eof

:0755
adb push %1 "%file%">nul 2>nul
if %errorlevel%==1 call :pushfailed "%file%"
echo INFO:成功上传%file%
adb shell chmod 0755 "%file%">nul 2>nul
goto :eof
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:108495次
    • 积分:1242
    • 等级:
    • 排名:千里之外
    • 原创:8篇
    • 转载:81篇
    • 译文:0篇
    • 评论:1条
    文章分类