I am currently working on a batch script and would like to add new paths to the system environment variables via registry command. Here is my current code:
set newPath=%path%;%NODE_MODULES_DIR%;%NODE_MODULES_DIR%\electron\dist
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Sessions Manager\Environment" /v Path /t REG_EXPAND_SZ /d "%newPath%" /f
call logoff
I do a reg add
with new paths. And as I understand, since changes will not take effect until after a logout/restart, I added call logoff
to force user to log out.
Problem is when I log back in, I still can't see my new paths under system environment variables.
I do not want to use the setx
command because of the 1024 limitation.
Can someone help? Thanks!!