Batch file that adds to PATH

Discussion in 'Windows - General discussion' started by stoke49, Oct 3, 2009.

  1. stoke49

    stoke49 Member

    Joined:
    Oct 3, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    11
    I want to make a .bat file that adds a directory to the Widows XP environment varible. How do I do this?
     
  2. dailun

    dailun Active member

    Joined:
    Mar 16, 2006
    Messages:
    3,074
    Likes Received:
    0
    Trophy Points:
    66
    edited because my first answer wasn't quite correct.

    From http://vlaurie.com/computers2/Articles/environment.htm

    In the command line and in batch files, PATH can be modified by the command
    path = dir1;dir2;dir3
    This command will create a PATH environment variable consisting of the three directories dir1, dir2, and dir3. Note that the directory names are separated by a semicolon in the command statement. (An alternate form omits the "equals" sign.) This command will replace any previous directories that were in the PATH variable. To add a directory "newdir" to the current path use the statement
    path = %PATH%;newdir

    It is essential to remember that any changes that are made in a command window only endure until the window is closed. For permanent changes, use the method discussed in another section. It is also possible to use the command-line executable setx.exe that is contained in the Windows XP Service Pack 2 Support Tools.

    The other section is here:

    http://vlaurie.com/computers2/Articles/environment.htm#editing

    and has some other options that should help.
     
    Last edited: Oct 4, 2009

Share This Page