How to change PATH in Windows

Asked

Viewed 53,653 times

7

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

  • Which windows you are using?

6 answers

16


If you want to change the PATH from the command line/from inside your program calling the shell, the command is this:

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

The set serves to assign values to environment variables; on the right side, the %PATH% reads the value of the variable PATH and includes her in the list (so that she will have the old ways 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. is valid 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 Windows version (the other answers also give examples). If you want to do this programmatically, then you may need to tinker with Windows records. See this question in the SOEN for more details. An answer indicates that it is possible to use the command setx instead of the set to make the change permanent, I cannot confirm this as I have never used this command before (nor do I know from which version it is available):

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

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

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

  • I chose yours because it is the best answer indeed and it applies to all available windows versions. Thank you for the reply.

  • 1

    +1 because cited alternative to define permanently via command line. I would even reply set PATH=%PATH%;XPTO but with standard cmd there is no way to permanently define how it happens in Linux. You bypassed it.

9

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

Right-click the Computer and choose Properties:

inserir a descrição da imagem aqui

Choose "Advanced System Settings"

inserir a descrição da imagem aqui

Will open the following window:

inserir a descrição da imagem aqui

Click environment variables, the following window will open:

inserir a descrição da imagem aqui

Select Path and click Edit

  • 1

    +1 very well formulated illustrated reply. Thank you

5

Follow these steps (Windows 7):

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

  • Cool, I didn’t know that in Portugal called the "mouse" mouse. Here in Brazil we call the mouse.

  • +1 quick and assertive response.

  • 3

    @Maicon Carraro It is the old question about what should be translated or not. I had noticed that there are terms that Brazilians translate and Portuguese do not and vice versa.

5

Can be changed modifying the system record in all versions of Windows, this way making up permanent the change.

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

Know how to change registry variables in windows.

4

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

  • 1

    +1 we ended up finding from the same source this answer, Java site.

  • 2

    Hehe, yeah, yeah, yeah...

2

Windows 8

  1. Drag the mouse pointer (Mouse) 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, find PATH and click on it.
  5. In the Edit dialog, modify PATH adding the class location to the value of PATH. If you don’t have the item PATH, you can choose to add a new variable and add PATH as the name and location of the class as the value.
  6. Close the window.

Windows 7

  1. Select Computer from the Start menu
  2. Relate the item
  3. Choose System Properties from the context menu
  4. Click the Advanced System Settings tab > Advanced
  5. Click Environment Variables, under System Variables, find PATH and click on it.
  6. In the Edit dialog, modify PATH by adding the class location to the value of PATH. If you don’t have the item PATH, you can choose to add a new variable and add PATH as the name and location of the class as the value.

Windows XP

  1. Start -> Control Panel -> System -> Advanced
  2. Click Environment Variables, under System Variables, find PATH and click on it.
  3. In the Edit dialog, modify PATH adding the class location to the value of PATH. If you don’t have the item PATH, you can choose to add a new variable and add PATH as the name and location of the class 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 on the Advanced tab (Advanced system settings link in Vista)
  4. In the Edit dialog, modify PATH adding the class location to the value of PATH. If you don’t have the item PATH, you can choose to add a new variable and add PATH as the name and location of the class as the value.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.