1
0

More fixes

This commit is contained in:
Benjamin Höglinger-Stelzer 2023-06-06 15:18:33 +02:00
parent 17fdc5a7f3
commit a87f3c0764

View File

@ -5,18 +5,20 @@ rem cobbled together by https://github.com/nefarius
set MYDIR=%~dp0 set MYDIR=%~dp0
pushd "%MYDIR%" pushd "%MYDIR%"
rem grab current value
for /f "tokens=1,2*" %a in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v path') do set currentValue=%c
SETLOCAL EnableDelayedExpansion SETLOCAL EnableDelayedExpansion
NET SESSION >nul 2>&1 NET SESSION >nul 2>&1
IF %ERRORLEVEL% EQU 0 ( IF %ERRORLEVEL% EQU 0 (
for /d %%d in (*.*) do ( for /d %%d in (*.*) do (
rem grab current value set newValue=%MYDIR%%%d
for /f "tokens=1,2*" %a in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v path') do set currentValue=%c
rem concat previous and new value rem concat previous and new value
set value=%currentValue%;%MYDIR%%%d set currentValue=%currentValue%;%newValue%
rem write back new value rem write back new value
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path /t REG_EXPAND_SZ /d "%value%" /f 2>nul reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path /t REG_EXPAND_SZ /d "%currentValue%" /f 2>nul
echo Added !value! to system PATH echo Added !currentValue! to system PATH
) )
) ELSE ( ) ELSE (
ECHO You need to run this script as Administrator ECHO You need to run this script as Administrator