From 7b4dc3574b72ccce1b64aa61a15bde1e747568ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20H=C3=B6glinger-Stelzer?= Date: Tue, 6 Jun 2023 15:03:22 +0200 Subject: [PATCH] Implemented add_to_path.cmd --- add_to_path.cmd | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 add_to_path.cmd diff --git a/add_to_path.cmd b/add_to_path.cmd new file mode 100644 index 0000000..61f15bf --- /dev/null +++ b/add_to_path.cmd @@ -0,0 +1,23 @@ +@echo off +@setlocal +rem cobbled together by https://github.com/nefarius + +set MYDIR=%~dp0 +pushd "%MYDIR%" + +SETLOCAL EnableDelayedExpansion + +NET SESSION >nul 2>&1 +IF %ERRORLEVEL% EQU 0 ( + for /d %%d in (*.*) do ( + set value=%MYDIR%%%d + echo Adding !value! to system PATH + reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path /t REG_EXPAND_SZ /d "%value%" /f + ) +) ELSE ( + ECHO You need to run this script as Administrator +) + +popd +endlocal +pause