Dos烧录脚本

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

  1 @echo off
  2 
  3 
  4 
  5 
  6 ::路径注意增加
  7 @set flashpath=Z:DT380LINUXandroidout	argetproductmsm8953_64
  8 @set Dynamic_library_Path=Z:msm8909out	argetproductmsm8909objlibsensors.msm8909.so
  9 @set Sensors_conf=Z:DT380LINUXandroidvendorqcomproprietarysensorsdsps
eg_defaultssensor_def_qcomdev.conf
 10 @set boot_image=%flashpath%boot.img
 11 @set mbn_image=%flashpath%emmc_appsboot.mbn
 12 @set userdata_image=%flashpath%userdata.img
 13 @set system_image=%flashpath%system.img
 14 @set persist_image=%flashpath%persist.img
 15 @set ramdisk_image=%flashpath%ramdisk.img
 16 @set recover_image=%flashpath%recovery.img
 17 @set cache_image=%flashpath%cache.img
 18 @set Dynamic_library=%Dynamic_library_Path%
 19 @set Dynamic_library_Board_Path=/system/lib/
 20 
 21 ::初始化,下面便是判断是否有文件
 22 @set Image_Index=0
 23 @set Image_Current-path=0
 24 @set Image_Length=7
 25 @set Image[0]-path=%boot_image%
 26 @set Image[1]-path=%mbn_image%
 27 @set Image[2]-path=%system_image%
 28 @set Image[3]-path=%persist_image%
 29 @set Image[4]-path=%ramdisk_image%
 30 @set Image[5]-path=%recover_image%
 31 @set Image[6]-path=%cache_image%
 32 @set Image[7]-path=%Dynamic_library%
 33 ::初始化
 34 
 35 :LoopStart
 36 
 37 ::清空字符串
 38 @set Image_Current-path=0
 39 
 40 if %Image_Index% equ %Image_Length% goto BeginRun
 41 
 42 for /f "usebackq tokens=1,2,3 delims==-" %%a in (`set Image[%Image_Index%]`) do (
 43     set Image_Current-%%b=%%c
 44 )
 45 
 46 if exist %Image_Current-path% (
 47     @echo 该路径%Image_Current-path%存在......
 48     @echo.
 49 ) else (
 50     @echo %Image_Current-path%
 51     @echo 请确定该文件文件是否存在?如果不存在,请确定路径,打开脚本重新设置。10秒后关闭....
 52     @ping -n 10 127.0.0.1>nul
 53     exit
 54 )
 55 
 56 @set /a Image_Index=%Image_Index%+1
 57 
 58 goto LoopStart
 59 
 60 :BeginRun
 61 @echo 检查Android镜像文件已经完成,请继续下一步......
 62 @echo.
 63 
 64 @echo 0、同时烧录emmc_appsboot.mbn和boot.img
 65 @echo 1、烧录boot.img
 66 @echo 2、烧录aboot.img
 67 @echo 3、烧录persist.img
 68 @echo 4、烧录ramdisk.img
 69 @echo 5、烧录recovery.img
 70 @echo 6、烧录system.img
 71 @echo 7、烧录cache.img
 72 @echo 8、烧录所有镜像
 73 @echo 9、重新推进sensor.so
 74 ::@echo 10、烧录并更新adsp架构下的sensor文件
 75 
 76 @set /p option=请先设置路径后,再输入要烧录的选项:
 77 
 78 
 79 if "%option%" == "9" (
 80 adb root
 81 adb wait-for-device
 82 adb remount
 83 @echo 重新推进sensor........
 84 adb push %Dynamic_library% %Dynamic_library_Board_Path%
 85 adb reboot
 86 @echo 正在重启...... 5秒后关闭....
 87 @ping -n 5 127.0.0.1>nul
 88 
 89 exit
 90 )
 91 
 92 
 93 ::判断是否进入fastboot模式
 94 fastboot devices>1.txt
 95 set /p message=<1.txt
 96 del 1.txt
 97 if not defined message (
 98     echo 正处于adb mode模式.....
 99     adb wait-for-device
100     adb reboot-bootloader
101 ) else ( 
102     echo 正处于fastboot mode模式.....
103 )
104 
105 
106 @echo.
107 
108 if "%option%" == "0" (
109 @echo 同时烧录emmc_appsboot.mbn和boot.img........
110 fastboot flash boot %boot_image%
111 fastboot flash aboot %mbn_image%
112 )
113 
114 if "%option%" == "1" (
115 @echo 烧录boot.img........
116 fastboot flash boot %boot_image%
117 )
118 
119 if "%option%" == "2" (
120 @echo 烧录aboot.img........
121 fastboot flash aboot %mbn_image%
122 )
123 
124 if "%option%" == "3" (
125 @echo 烧录persist.img..........
126 fastboot flash persist %persist_image%
127 )
128 
129 if "%option%" == "4" (
130 @echo 烧录ramdisk.img..........
131 fastboot flash ramdisk %ramdisk_image%
132 )
133 
134 if "%option%" == "5" (
135 @echo 烧录recovery.img...........
136 fastboot flash recovery %recover_image%
137 )
138 
139 if "%option%" == "6" (
140 @echo 烧录system.img........
141 fastboot flash system %system_image%
142 )
143 
144 if "%option%" == "7" (
145 @echo 烧录cache.img...........
146 fastboot flash cache %cache_image%
147 )
148 
149 if "%option%" == "8" (
150 @echo 烧录所有镜像.............
151 fastboot flash boot %boot_image%
152 fastboot flash aboot %mbn_image%
153 fastboot flash persist %persist_image%
154 fastboot flash ramdisk %ramdisk_image%
155 fastboot flash recovery %recover_image%
156 fastboot flash system %system_image%
157 fastboot flash cache %cache_image%
158 fastboot flash userdata %userdata_image%
159 )
160 
161 
162 
163 
164 fastboot reboot
165 @echo 正在重启 请稍后......
166 adb wait-for-device
167 adb root
168 adb wait-for-device
169 
170 
171 @ping -n 5 127.0.0.1>nul
172 adb shell dmesg > kmesg.log
173 @echo kernel log已经导出.....
174 
175 
176 
177 @echo [烧录成功,暂停5秒自动关闭]
178 @ping -n 5 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

综上所述:脚本好恶心!

原文地址:https://www.cnblogs.com/linhaostudy/p/8361527.html