提交 0f6a3423 编写于 作者: J James Ko

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
上级 1202fc4d
@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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册