Batch file to add variable to PATH

Hi,

Under system properties - Environment Variables - System variables - the Variable PATH I want to add the following ;C:\Program Files\Internet Explorer.

I have attached a screen shot.

I want to do this by using a batch script and I want to add to the existing variable.

Thanks

Luke

Environment-variable.bmp
luketrAsked:
Who is Participating?
 
pritamduttCommented:
1. You are required to surround path containing spaces with "" 
2. In order to make permanent changes for the system you need to administrative access to the system would be required. you could choose to use one of following methods
a) SETX.exe .. it had been available post Win XP SP 2 this works the same way as SET command, but makes permanent changes
b) use reg command to programatically set  registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment for the value of PATH
0
 
pritamduttCommented:
My Quick Question do you want to store the changes permanently? or for runtime only.

in case you want to use for the current batchfile you can use the following command

SET PATH=%PATH%;new path

This will add your new path to existing list of PATHs

0
 
luketrAuthor Commented:
I've just tried it and it hasn't work, i need the change to be done permanetly.


SET PATH=%PATH%;C:\Program Files\Internet Explorer
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
pivarCommented:
Hi,

You can use SETX to permanently set the PATH.

SETX PATH yourpath

Run SETX /? for help.

/peter
0
 
Martin_J_ParkerCommented:
You could use setx.exe from the Windows Resource kit or from M$ download:
http://www.microsoft.com/download/en/details.aspx?id=4200

Alternatively you can edit the registry key for "Path" in
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment]
The problem with changing registry keys is if you screw up the registry path your machine will become unusable - so be careful!

There's also the question of whether it's the local user's path or the system one for all users that you want to change.

There is a third party program called editpath which is reputedly good, but I haven't had firsthand experience:
http://www.brothersoft.com/editpath-316619.html
0
 
Martin_J_ParkerCommented:
That'll teach me not to leave a session open for a couple of hours before returning to a question - looks like pritamdutt beat me to most of that!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.