Dos烧录脚本

时间:2023-03-09 08:43:35
Dos烧录脚本

Dos命令之前更改的太简单,现在加入判断是否进入fasboot模式和判断Android镜像是否存在;代码已经尽量简化成这样,dos命令功能还是比较不好用的,用了一下午的时间。。。

 @echo off

 ::路径注意增加\
@set flashpath=Z:\DT380\LINUX\android\out\target\product\msm8953_64\
@set Dynamic_library_Path=Z:\msm8909\out\target\product\msm8909\obj\lib\sensors.msm8909.so
@set Sensors_conf=Z:\DT380\LINUX\android\vendor\qcom\proprietary\sensors\dsps\reg_defaults\sensor_def_qcomdev.conf
@set boot_image=%flashpath%boot.img
@set mbn_image=%flashpath%emmc_appsboot.mbn
@set userdata_image=%flashpath%userdata.img
@set system_image=%flashpath%system.img
@set persist_image=%flashpath%persist.img
@set ramdisk_image=%flashpath%ramdisk.img
@set recover_image=%flashpath%recovery.img
@set cache_image=%flashpath%cache.img
@set Dynamic_library=%Dynamic_library_Path%
@set Dynamic_library_Board_Path=/system/lib/ ::初始化,下面便是判断是否有文件
@set Image_Index=
@set Image_Current-path=
@set Image_Length=
@set Image[]-path=%boot_image%
@set Image[]-path=%mbn_image%
@set Image[]-path=%system_image%
@set Image[]-path=%persist_image%
@set Image[]-path=%ramdisk_image%
@set Image[]-path=%recover_image%
@set Image[]-path=%cache_image%
@set Image[]-path=%Dynamic_library%
::初始化 :LoopStart ::清空字符串
@set Image_Current-path= if %Image_Index% equ %Image_Length% goto BeginRun for /f "usebackq tokens=1,2,3 delims==-" %%a in (`set Image[%Image_Index%]`) do (
set Image_Current-%%b=%%c
) if exist %Image_Current-path% (
@echo 该路径%Image_Current-path%存在......
@echo.
) else (
@echo %Image_Current-path%
@echo 请确定该文件文件是否存在?如果不存在,请确定路径,打开脚本重新设置。10秒后关闭....
@ping -n 127.0.0.1>nul
exit
) @set /a Image_Index=%Image_Index%+ goto LoopStart :BeginRun
@echo 检查Android镜像文件已经完成,请继续下一步......
@echo. @echo 、同时烧录emmc_appsboot.mbn和boot.img
@echo 、烧录boot.img
@echo 、烧录aboot.img
@echo 、烧录persist.img
@echo 、烧录ramdisk.img
@echo 、烧录recovery.img
@echo 、烧录system.img
@echo 、烧录cache.img
@echo 、烧录所有镜像
@echo 、重新推进sensor.so
::@echo 、烧录并更新adsp架构下的sensor文件 @set /p option=请先设置路径后,再输入要烧录的选项: if "%option%" == "" (
adb root
adb wait-for-device
adb remount
@echo 重新推进sensor........
adb push %Dynamic_library% %Dynamic_library_Board_Path%
adb reboot
@echo 正在重启...... 5秒后关闭....
@ping -n 127.0.0.1>nul exit
) ::判断是否进入fastboot模式
fastboot devices>.txt
set /p message=<.txt
del .txt
if not defined message (
echo 正处于adb mode模式.....
adb wait-for-device
adb reboot-bootloader
) else (
echo 正处于fastboot mode模式.....
) @echo. if "%option%" == "" (
@echo 同时烧录emmc_appsboot.mbn和boot.img........
fastboot flash boot %boot_image%
fastboot flash aboot %mbn_image%
) if "%option%" == "" (
@echo 烧录boot.img........
fastboot flash boot %boot_image%
) if "%option%" == "" (
@echo 烧录aboot.img........
fastboot flash aboot %mbn_image%
) if "%option%" == "" (
@echo 烧录persist.img..........
fastboot flash persist %persist_image%
) if "%option%" == "" (
@echo 烧录ramdisk.img..........
fastboot flash ramdisk %ramdisk_image%
) if "%option%" == "" (
@echo 烧录recovery.img...........
fastboot flash recovery %recover_image%
) if "%option%" == "" (
@echo 烧录system.img........
fastboot flash system %system_image%
) if "%option%" == "" (
@echo 烧录cache.img...........
fastboot flash cache %cache_image%
) if "%option%" == "" (
@echo 烧录所有镜像.............
fastboot flash boot %boot_image%
fastboot flash aboot %mbn_image%
fastboot flash persist %persist_image%
fastboot flash ramdisk %ramdisk_image%
fastboot flash recovery %recover_image%
fastboot flash system %system_image%
fastboot flash cache %cache_image%
fastboot flash userdata %userdata_image%
) fastboot reboot
@echo 正在重启 请稍后......
adb wait-for-device
adb root
adb wait-for-device @ping -n 127.0.0.1>nul
adb shell dmesg > kmesg.log
@echo kernel log已经导出..... @echo [烧录成功,暂停5秒自动关闭]
@ping -n 127.0.0.1>nul

其中用到的相应内容有dos命令for循环的使用:

参考博客:http://blog.csdn.net/wh_19910525/article/details/7912440

Bat数组使用的情况:http://www.jb51.net/article/67630.htm

我自己整理的For f中的tokens和delims怎么用?直接拉上百度知道,整理得到的。就不管链接了,贴上我的有道云笔记链接就行了:http://note.youdao.com/noteshare?id=728873fd0d9b1ea50a73aed3d476135e&sub=FD0225FD68AC400C8C909FE85C293202

bat脚本回车命令是echo.

批处理语句判断变量是否为空的方法:http://www.bathome.net/thread-4046-1-8.html

综上所述:脚本好恶心!