/build/static/layout/Breadcrumb_cap_w.png
10/24/2018 187 views
I'm facing a dilemma I can't quite seem to find a solution for.   In our system environment variables I need to add the path \\server03\folder without overwriting what is already stored in PATH.  

I've tested the setx command and it works fine but a lot of our machines have more than 1024 characters in the PATH variable and setx truncates at 1024.   This, obviously, is problematic.   

I'm creating a batch file to install an application client from the \\server03\folder location and would like something simple to add to the PATH variable.  The simplest solution I can think of would be to create a registry key that contains every possible entry people could have in PATH and import that but I know I won't catch everything and some app will break because of it.

Any ideas?
0 Comments   [ + ] Show comments

Comments


All Answers

0
I'm not sure how you would append this, but editing the registry might be the trick:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

A reboot is required.

Answered 10/24/2018 by: worzie
Brown Belt

  • Yeah, that's the reg key I would have to update if I had to create a new %PATH% for everyone. Was hoping I wouldn't have to do that. We have a pretty mixed environment of Win7, Win10, XenApp, and XenDesktop machines and there are variations in the %PATH% variable so I'd like to not have to overwrite what is already out there.

    The SETX command works well except for it truncating at 1024 characters. Some of ours are well beyond 1024, so they would lose data.
  • Apparently what looks to be happening is the path variables are getting parsed out instead of remaining as variables.

    I see others having this issue have tried a couple ways:

    https://stackoverflow.com/questions/19287379/how-do-i-add-to-the-windows-path-variable-using-setx-having-weird-problems/45566845#45566845

    for /f "usebackq tokens=2,*" %A in ('reg query HKCU\Environment /v PATH') do set my_user_path=%B

    setx PATH "C:\Python27;C:\Python27\Scripts;%my_user_path%"

    Alternatively use a PowerShell here https://gallery.technet.microsoft.com/scriptcenter/Edit-and-shorten-PATH-37ef3189#content