How to change PATH on Windows

I would like to know how I can change the variable PATH in the Windows environment.

I am a linux user but I know that windows also allows the use of this environment variable to find its executables.

Author: Gabriel Gartz, 2014-02-10

6 answers

If you want to change PATH from the command line/from within your program by invoking the shell, the command is this:

set PATH=%PATH%;C:\minha\nova\pasta

set serves to assign values to environment variables; on the right side, the %PATH% reads the value of the variable PATH and includes it in the list (so it will have the old paths and the new path you are adding). And folders in Windows are separated by ; (and not by : as in *NIX). Note that this change is temporary (i.e. holds until you close the terminal/your program finishes running).

If your intention is to change this variable permanently (for all users or for a specific user), then look for the instructions for your specific version of Windows (the other answers also give examples). If you want to do this programmatically, then you may need to tinker with Windows logs. See this question in Soen for more details. A response indicates that it is possible to use the command setx instead of set to make the change permanent, I can't confirm this as I've never used this command before (I don't even know from what version it's available):

setx PATH "%PATH%;C:\minha\nova\pasta"

setx PATH "%PATH%;C:\minha\nova\pasta" /m

(the first changes only to the current user, the second to all users)

 15
Author: mgibsonbr, 2017-05-23 12:37:27

Basically you have to access the environment variables, regardless of which Windows you are using.

Right-click on the computer and choose Properties:

insert the description of the image here

Choose "Advanced System Settings"

insert the description of the image here

Will open the following window:

insert the description of the image here

Click environment variables, the following window will open:

insert the description of the image here

Select Path and click Edit

 8
Author: Math, 2014-02-10 12:26:12

Follow these steps (Windows 7):

Button Iniciar
Right mouse button on Computador
On the left side of the screen that appeared choose Definições avançadas do sistema
Choose Variáveis de ambiente

 5
Author: ramaral, 2014-02-10 12:23:59

Can be changed by modifying the system registry in all versions of Windows, thus making permanent the change.

Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment and change the variable Path.

Learn how to change Registry variables in Windows.

 5
Author: Gabriel Gartz, 2017-04-13 12:59:42

Windows 8

    Arraste o ponteiro do Mouse até o canto inferior Direito da tela
    Clique no ícone Pesquisar e digite Painel de Controle
    Clique em -> Painel de Controle -> Sistema -> Avançado
    Clique em Variáveis de Ambiente, em Variáveis do Sistema, localize PATH e clique nele.
    Na janelas Editar, modifique PATH adicionando a localização da classe para o valor de PATH. Caso você não tenha o item PATH, será possível optar por adicionar uma nova variável e adicionar PATH como o nome e o local da classe como o valor.
    Feche a janela.

Windows 7

    Selecione Computador no menu Iniciar
    Escolha Propriedades do Sistema no menu de contexto
    Clique na guia Definições avançadas do sistema > Avançado
    Clique em Variáveis de Ambiente, em Variáveis do Sistema, localize PATH e clique nele.
    Na janelas Editar, modifique PATH adicionando a localização da classe para o valor de PATH. Caso você não tenha o item PATH, será possível optar por adicionar uma nova variável e adicionar PATH como o nome e o local da classe como o valor.

Windows XP

    Iniciar -> Painel de Controle -> Sistema -> Avançado
    Clique em Variáveis de Ambiente, em Variáveis do Sistema, localize PATH e clique nele.
    Na janelas Editar, modifique PATH adicionando a localização da classe para o valor de PATH. Caso você não tenha o item PATH, será possível optar por adicionar uma nova variável e adicionar PATH como o nome e o local da classe como o valor.
    Feche a janela.

Windows Vista

    Clique com o botão direito do mouse no ícone Meu computador
    Escolha Propriedades no menu de contexto
    Clique na guia Avançado (link Definições avançadas do sistema no Vista)
    Na janelas Editar, modifique PATH adicionando a localização da classe para o valor de PATH. Caso você não tenha o item PATH, será possível optar por adicionar uma nova variável e adicionar PATH como o nome e o local da classe como o valor.

Source: http://www.java.com/pt_BR/download/help/path.xml

 4
Author: Jefferson Alison, 2014-02-10 12:38:48

Windows 8

  1. drag the mouse pointer to the bottom right corner of the screen
  2. click the Search icon and type control panel
  3. click - > Control Panel -> System - > Advanced
  4. Click environment variables, under System Variables, locate PATH and click it.
  5. in the edit windows, modify PATH by adding the class location to the value of PATH. If you do not have the item PATH, you can choose to add a new variable and add PATH as the class name and location as the value.
  6. close the window.

Windows 7

  1. select computer from the Start menu
  2. relate item
  3. choose System Properties from the context menu
  4. click the Advanced System Settings tab > Advanced
  5. Click environment variables, under System Variables, locate PATH and click on it.
  6. in the edit windows, modify PATH by adding the class location to the value of PATH. If you don't have the PATH item, you can choose to add a new variable and add PATH as the class name and location as the value.

Windows XP

  1. Start -> Control Panel -> System - > Advanced
  2. Click environment variables, under System Variables, locate PATH and click it.
  3. Na edit windows, modify PATH by adding the class location to the value of PATH. If you don't have the PATH item, you can choose to add a new variable and add PATH as the class name and location as the value.
  4. close the window.

Windows Vista

  1. right-click the My Computer icon
  2. choose Properties from the context menu
  3. click the Advanced tab (link Advanced System settings in Vista)
  4. in the edit windows, modify PATH by adding the class location to the value of PATH. If you don't have the PATH item, you can choose to add a new variable and add PATH as the class name and location as the value.
 2
Author: Gabriel Gartz, 2014-02-10 12:32:09