How to append PATH to registry ?

  • Thread starter Thread starter codefixer
  • Start date Start date
C

codefixer

Hi,

I am wondering how can I append path to existing path in the registry.
I want to add d:\tools for the PATH variable in
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment]


Thanks.
 
setx.exe from the resource kit.


--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

| Hi,
|
| I am wondering how can I append path to existing path in the registry.
| I want to add d:\tools for the PATH variable in
| [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
| Manager\Environment]
|
|
| Thanks.
|
 
Dave said:
setx.exe from the resource kit.

Unfortunately I won't have it. I tried the following

In a batch file, set path=d:\tools;%path% and then dump this to a reg
file.
Then call the reg file. For some reason, it still doesn't get
imported.(I click Yes when it prompts me)
My reg file looks like this

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment]
"Path"="d:\tools;D:\WINDOWS\system32;D:\WINDOWS;D:\WINDOWS\System32"

Any idea why Path would not get appended into the registry ?

Thanks
--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

| Hi,
|
| I am wondering how can I append path to existing path in the registry.
| I want to add d:\tools for the PATH variable in
| [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
| Manager\Environment]
|
|
| Thanks.
|
 
That would probably replace "Path" with a type Reg_Sz string. "Path" needs
to be type Reg_Expand_Sz hence it is stored as an array of hex values in a
*.reg file.

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

|
| Unfortunately I won't have it. I tried the following
|
| In a batch file, set path=d:\tools;%path% and then dump this to a reg
| file.
| Then call the reg file. For some reason, it still doesn't get
| imported.(I click Yes when it prompts me)
| My reg file looks like this
|
| Windows Registry Editor Version 5.00
|
| [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
| Manager\Environment]
| "Path"="d:\tools;D:\WINDOWS\system32;D:\WINDOWS;D:\WINDOWS\System32"
|
| Any idea why Path would not get appended into the registry ?
|
| Thanks
 
In said:
Dave said:
setx.exe from the resource kit.

Unfortunately I won't have it. I tried the following

In a batch file, set path=d:\tools;%path% and then dump this to
a reg file.
Then call the reg file. For some reason, it still doesn't get
imported.(I click Yes when it prompts me)
My reg file looks like this

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment]
"Path"="d:\tools;D:\WINDOWS\system32;D:\WINDOWS;D:\WINDOWS\System
32"

Any idea why Path would not get appended into the registry ?

Thanks
--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

| Hi,
|
| I am wondering how can I append path to existing path in the registry.
| I want to add d:\tools for the PATH variable in
| [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
| Manager\Environment]
|
|
| Thanks.

There is also pathman.exe (Resource Kit)

and how about EditPath.exe
http://internet.cybermesa.com/~bstewart/misctools.html
http://internet.cybermesa.com/~bstewart/files/epath1.zip
If you cannot get ResourceKit or Support Tools but 3rd-party is okay,
then try editpath. Far easier than direct registry manipulation via
..REG files for this task.

Or you might use reg.exe in a script perhaps.

You may have an additional problem in batch by not having escaped the
"%" sybols with "^".
 
Hi,

I am wondering how can I append path to existing path in the registry.
I want to add d:\tools for the PATH variable in
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment]


Thanks.

See tips 4263 and 8840 in the 'Tips & Tricks' at http://www.jsiinc.com

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com


I did it an ugly way but effective. I used vbscript to capture the
contents of the current value. I then appended the new value to it and
wrote it back

'************************************************************
'* Modifying The System Path With New Entries *
'************************************************************
Dim ExistingPath, NewPath
Set oShell = WScript.CreateObject("WScript.Shell")
Set oEnv = oShell.Environment("SYSTEM")

'************************************************************
'* Add your Path Entry Here *
'************************************************************
ExistingPath = oEnv("PATH")
NewPath = ExistingPath & ";" & "C:\ADD SOME PATH HERE"
oEnv("PATH") = NewPath 'WRITE NEW PATH, INCLUDING OLD ONE
 
Back
Top