Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8895245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:43:37+00:00 2026-06-14T23:43:37+00:00

In environment variables I have a PATH variable for both user variables and system

  • 0

In environment variables I have a PATH variable for both user variables and system variables.

In a batch script, in order for me to append the user PATH variable with a new given path, I need to select the current value. Unfortunately %PATH% returns a combination of the user variable and the system variable.

Of course I only want to add a new custom path value to the user variable. There is no point in enhancing it with the system path as well. That’s why I have 2 variables.

Thanks in advance.

Edit: Found in the documentation the following statement:

The %PATH% variable is set as both a system and user variable, the 2 values are combined to give the PATH for the currently logged in user….

Example:

User variables:

PATH
value: c:\dev

System variables

PATH
value: c:\Program Files

What I want to do, is to add to the user variable the value: c:\tmp, so that in the end PATH will have the value: c:\dev;c:\tmp

But, if open a cmd window:

echo %PATH%
c:\Program Files;c:\dev

so the setx will do the following

setx path "%path%;c:\tmp"

open new cmd

echo %PATH%
c:\Program Files;c:\dev;c:\tmp

And that is wrong, because I only needed c:\dev;c:\tmp

I hope I was more clear this time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:43:39+00:00Added an answer on June 14, 2026 at 11:43 pm

    How are you modifying the variables?

    There is only one environment variable PATH, so you can go ahead and change it. These changes are transient (and local to your process and its children).

    There are two (actually more) persistent places in Registry from which the environment variables are initialized when a process is created. You can modify them using reg utility. There is no ambiguity since they are separate:

    • HKEY_CURRENT_USER\Environment
    • HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

    You may have to re-login for changes in Registry to take effect (I don’t remember whether there’s a programmatic way to notify explorer that these settings have changed). Also note that by default child processes inherit the environment of their parent (unless the parent takes special measures to do otherwise), so e.g. if you launch a cmd window and later modify the environment via system settings dialog, applications started from that cmd won’t see the changes.

    [UPD] You can get the value of user-specific environment variable from registry using reg utility:

    reg query HKCU\Environment /v PATH
    

    Though you’ll have to filter its output for the actual value, as it spits out some useless text. Here an example incantation:

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

    It will store the result in the environment variable value. Remember to double %‘s when using it in a batch file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script to get and set user's Windows environment variables on other
I have added Path variable 'C:\Program Files\Java\jdk1.6.0_21\bin' in Environment Variables, but it still gives
Is it possible for the apache2 user, http, to have environment variables like normal
I am trying to add C:\xampp\php to my system PATH environment variable in Windows.
I have set JAVA_HOME = C:\Program Files\Java\jdk1.6.0_26 in user defined variables and system variables
I have two environment variables in apache config, I want to concatenate them into
I have an IOS application which uses environment variables and am able to set
does someone have an idea how to get the environment variables on Google-AppEngine ?
CGI scripts should have access to a list of environment variables set by the
For some reason I have to access Jenkins global environment variables like BUILD ID,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.