Last active
September 7, 2018 06:45
-
-
Save tilkinsc/f6718ca61d76085b064c3dca02f96017 to your computer and use it in GitHub Desktop.
Batch file you can stick in C:\Windows or C:\Windows\System32 after setting paths in environment variables, which called will add those paths to PATH: using %ExamplePath% adds C:\Whatever;C:\Whatever2 to %PATH%
This file contains 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
REM Created by: http://github.com/tilkinsc | |
REM Use the -v or /v switch anywhere to see the command issued. | |
REM Adds supplied path to the %PATH% variable, supports multiple paths per variable | |
REM Usage: using %EnvVariable% [-v] | |
REM Example: | |
REM set examp=C:\Whatever;C:\Whatever2 | |
REM using %examp% -v | |
REM echo %path% | |
REM And the output would be: Processing path with "using C:\Whatever;C:\Whatever2 -v" | |
REM And the path would be: C:\Whatever;C:\Whatever2;C:\;C:\Windows;C:\Windows\System32... | |
REM Note: They are added first because of how Windows searches along path | |
@echo off | |
setlocal | |
set toecho=Processing path with "using %*" | |
for %%a in (%*) do ( | |
if [%%a] equ [-v] ( | |
echo %toecho% | |
set /a endcount+=1 | |
goto skipinv | |
) ELSE if [%%a] equ [/v] ( | |
echo %toecho% | |
set /a endcount+=1 | |
goto skipinv | |
) | |
call set "out=%%out%%;%%a" | |
:skipinv | |
SHIFT | |
) | |
( | |
endlocal | |
set "path=%out:~1%;%path%" | |
) | |
exit /b | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment