How to append PATH to registry ?

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.
 
D

Dave Patrick

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.
|
 
C

codefixer

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.
|
 
D

Dave Patrick

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
 
M

Mark V

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 "^".
 
N

NoneOfBusiness

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top