如果无法识别 adb,我希望终端自行关闭。ADB 是此脚本将用来检测设备的程序。以下是我的部分脚本
echo My name is RomBreaker
echo.
echo And I'm gonna flash your Nexus 5 back to stock 4.4.2
echo.
echo If ADB and Fastboot is not set properly, this of course is pointless
echo.
pause
echo.
echo Rebooting device into Bootloader via ADB
echo.
adb reboot-bootloader
echo.
echo If the above says "device not found" its because your in Fastboot
echo.
echo.........................................................................
echo.
echo If the above says "adb is not recognized" you didn't listen
echo.
我希望终端立即关闭。目标是编写一个 IF 或 Else IF,如果在 PC 上找不到程序“adb”,则关闭。当然,如果找到了,它将继续。
当 adb 无法识别时,我们就会得到这个。
'adb' is not recognized as an internal or external command,
operable program or batch file.
答案1
你可以检查执行后的 %errorlevel% 是否为 9009,所以
if %errorlevel% == 9009 exit
或者不要退出,而是做你需要做的事情。
答案2
除了 fede.evol 的答案之外,您还可以使用以下命令:
adb [any args you want to run] || exit