-
-
Save liuxk99/d7939696f2f2ffe8acc2bc0e4e888bfd to your computer and use it in GitHub Desktop.
Save the file in the android-platform-tools directory, using ANSI/GBK encoding, then double click the file to execute.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| :: Check if adb is already accessible in PATH | |
| C: | |
| cd C:\Windows\System32 | |
| where adb >nul 2>&1 | |
| if %errorlevel% equ 0 ( | |
| echo ADB is already in your PATH. | |
| echo Running 'adb version' to verify: | |
| adb version | |
| echo. | |
| echo No further action is needed. Setup aborted. | |
| pause | |
| exit /b | |
| ) | |
| :: Get the full path of the current batch file | |
| set "SCRIPT_PATH=%~f0" | |
| echo Full path of the current batch file: | |
| echo %SCRIPT_PATH% | |
| :: Get the directory where the batch file is located (remove trailing backslash) | |
| set "SCRIPT_DIR=%~dp0" | |
| set "SCRIPT_DIR=%SCRIPT_DIR:~0,-1%" | |
| echo. | |
| echo Directory of the batch file: | |
| echo %SCRIPT_DIR% | |
| :: Set ANDROID_HOME environment variable | |
| echo. | |
| echo Setting ANDROID_HOME environment variable... | |
| setx ANDROID_HOME "%SCRIPT_DIR%" | |
| :: Add %%ANDROID_HOME%% to the user's PATH | |
| echo. | |
| echo Adding %%ANDROID_HOME%% to the user PATH environment variable... | |
| setx PATH "%%ANDROID_HOME%%;%PATH%" | |
| echo. | |
| echo Setup complete! | |
| echo. | |
| echo Note: Environment variable changes will take effect in new command prompt windows. | |
| echo The current window's environment is not updated; please reopen CMD to see changes. | |
| pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment