From 0f6a3423e552bda58aeb9c85b7769430272e05b8 Mon Sep 17 00:00:00 2001 From: James Ko Date: Sun, 13 Dec 2015 15:54:31 -0500 Subject: [PATCH] Fix 1024 character limit with setx setx will automatically truncate the PATH to 1024 characters if it is longer than that. It also mixes the local user's path with the machine-wide path, which is no good. Unfortunately, the only way around this is running PowerShell to set the PATH manually. Related link: http://superuser.com/questions/387619/overcoming-the-1024-character-limit-with-setx --- script/install.bat | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/script/install.bat b/script/install.bat index 2eb5f97c..01796db7 100644 --- a/script/install.bat +++ b/script/install.bat @@ -1,5 +1,16 @@ @echo off CLS +goto checkPrivileges + +:appendToPath +set "RUNPS=powershell -NoProfile -ExecutionPolicy Bypass -Command" +set "OLDPATHPS=[Environment]::GetEnvironmentVariable('PATH', 'User')" +for /f "delims=" %%i in ('%RUNPS% "%OLDPATHPS%"') do ( + set OLDPATH=%%i +) +set NEWPATH=%OLDPATH%;%1 +%RUNPS% "[Environment]::SetEnvironmentVariable('PATH', '%NEWPATH%', 'User')" +goto :eof :checkPrivileges NET FILE 1>NUL 2>NUL @@ -28,7 +39,7 @@ set HUB_BIN_PATH="%LOCALAPPDATA%\GitHubCLI\bin" IF EXIST %HUB_BIN_PATH% GOTO DIRECTORY_EXISTS mkdir %HUB_BIN_PATH% set "path=%PATH%;%HUB_BIN_PATH:"=%" -1>NUL setx PATH "%PATH%" /M +call :apppendToPath %HUB_BIN_PATH:"=% :DIRECTORY_EXISTS :: Delete any existing programs -- GitLab