Skip to main content

Batch Files - Quick Reference Guide

info

Ensure you have admin privileges when running batch scripts that interact with ADB.


๐Ÿ” Conditional Branchingโ€‹

if %WIFI_CONNECTED% EQU 1 (
goto MDM_JOIGNABLE
)

๐Ÿ“‹ Menu Selectionโ€‹

OptionAction
1OS ADB Update
2OS OTA Update
3Install Master
4Exit
set /p choix=Enter your choice (1,2,3 or 4) :
if /I "%choix%"=="1" (goto :OS)
if /I "%choix%"=="2" (goto :OSOTA)
if /I "%choix%"=="3" (goto :MASTER)
if /I "%choix%"=="4" (goto :FIN)
goto question0

๐Ÿงญ GOTO Usageโ€‹

goto :label

๐Ÿ”„ Search and Replace in Filesโ€‹

powershell -Command "(gc config.ini) -replace 'USER01', '%username%' | Out-File config.ini" -encoding ASCII

๐Ÿงผ Clear Memory (Kill App Stacks)โ€‹

for /F "tokens=1,2,3,4" %%i in ('%adb% shell "am stack list | findstr \"Stack id\" "') do (
call :idstackcleaner "%%j"
)
:idstackcleaner
set id=%~1
set id2=%id:~3%
if %id2% NEQ 0 (
%adb% shell am stack remove %id2%
)
goto :eof