Batch file to add variable to PATH


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.



Who is Participating?
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
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

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


You can use SETX to permanently set the PATH.

SETX PATH yourpath

Run SETX /? for help.

You could use setx.exe from the Windows Resource kit or from M$ download:

Alternatively you can edit the registry key for "Path" in
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:
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!
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.