Adding to the path

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,689
106
Albuquerque, NM
prospero.unm.edu
How can I add a folder to the system path?

Not tested:

Code:
set /s path=%path;%newdir
Or, if the current value of the PATH environment variable might differ from the system variable:

Code:
set /s path=%@regquery["HKLM\System\CurrentControlSet\Control\Session Manager\Environment\path"];%newdir

Add a /E if you want your current path updated to reflect the new system path.
 
May 20, 2008
12,171
133
Syracuse, NY, USA
On Wed, 17 Jun 2009 20:41:08 -0500, CWBillow <> wrote:

|How can I add a folder to the system path?

Manually? ... use the ControlPanel System applet ... Advanced ... Environment
Variables

or

SET /S path=%path;new-dir
--
- Vince
 
Jul 12, 2008
287
0
Las Vegas, NV
Not tested:

Code:
set /s path=%path;%newdir
Or, if the current value of the PATH environment variable might differ from the system variable:

Code:
set /s path=%@regquery["HKLM\System\CurrentControlSet\Control\Session Manager\Environment\path"];%newdir

Add a /E if you want your current path updated to reflect the new system path.

Thanks Charles, Vince.

Regards,
Chuck
 

samintz

Scott Mintz
May 20, 2008
1,555
26
Solon, OH, USA
As you've already read, there are multiple ways to accomplish this.

I assume you mean to change the PATH environment variable for the SYSTEM
as opposed to the USER and have it take effect for all of Windows. If you
just want to change it for your current TCC session it gets even easier.

If you look up help on SET you can see there are a number of switches that
effect what gets set.

Display, create, modify, or delete environment variables.

SET [/A /D /E /P /R file... /S /U /V /X] [name[=][value ]]
file: One or more files containing variable definitions
/A(rithmetic) /S(ystem variables)
/D(efault variables) /U(ser variables)
/E(nv vars) /V(olatile variables)
/R(ead from file) /X override VariableExclude
/P(ause)

The SET /S command will set a value into the registry at the key
"HKLM\System\CurrentControlSet\Control\Session Manager\Environment".
The SET /U command will set a value into the registry at the key
"HKCU\Environment"
The SET /V command will set a value into the registry at the key
"HKCU\Volatile Environment"
The SET /D command will set a value into the registry at the key
"HKU\.DEFAULT\Environment"

Note that none of the above commands will modify your current TCC
environment with the following caveat:
If the "Update Environment on System Change" configuration option is set,
TCC will monitor the WM_SETTINGCHANGE message and update the environment
from the User, Volatile, and System registry entries. The update is done
whenever TCC displays the prompt (to prevent the environment from changing
in the middle of a command). Unless you have a specific need for this
option it's better not to enable it, as it can result in variables set by
TCC's parent process being destroyed.

If you specify the /E switch in combination with the above switches, both
the registry value and the current TCC environment will be set.

If you just want to modify the current TCC environment you can use either
ESET or SET.

SET PATH=%PATH;new_path

or ESET PATH

-Scott

CWBillow <> wrote on 06/17/2009 09:40:56 PM:


> How can I add a folder to the system path?
>
> Regards,
> Chuck Billow
>
>
>
>
 
May 20, 2008
3,515
4
Elkridge, MD, USA
samintz wrote:
...
| If you just want to modify the current TCC environment you can use
| either ESET or SET.
|
| SET PATH=%PATH;new_path
|
| or ESET PATH

... or use the PATH command, which is a legacy shorthand for "SET PATH":

PATH %path;addition
--
Steve
 

Similar threads