Batch file to add variable to PATH

Posted on 2011-10-05
Last Modified: 2012-05-12

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.



Question by:luketr
    LVL 9

    Expert Comment

    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


    Author Comment

    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
    LVL 22

    Expert Comment


    You can use SETX to permanently set the PATH.

    SETX PATH yourpath

    Run SETX /? for help.

    LVL 9

    Accepted Solution

    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
    LVL 10

    Expert Comment

    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:
    LVL 10

    Expert Comment

    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!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
    Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  ( Here (http…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now