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.
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)
Basically you have to access the environment variables, regardless of which Windows you are using.
Right-click on the computer and choose Properties:
Choose "Advanced System Settings"
Will open the following window:
Click environment variables, the following window will open:
Select Path and click Edit
Follow these steps (Windows 7):
Button
Iniciar
Right mouse button onComputador
On the left side of the screen that appeared chooseDefinições avançadas do sistema
ChooseVariáveis de ambiente
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
.
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.
Windows 8
- drag the mouse pointer to the bottom right corner of the screen
- click the Search icon and type control panel
- click - > Control Panel -> System - > Advanced
- Click environment variables, under System Variables, locate
PATH
and click it. - in the edit windows, modify
PATH
by adding the class location to the value ofPATH
. If you do not have the itemPATH
, you can choose to add a new variable and addPATH
as the class name and location as the value. - close the window.
Windows 7
- select computer from the Start menu
- relate item
- choose System Properties from the context menu
- click the Advanced System Settings tab > Advanced
- Click environment variables, under System Variables, locate
PATH
and click on it. - in the edit windows, modify PATH by adding the class location to the value of
PATH
. If you don't have thePATH
item, you can choose to add a new variable and addPATH
as the class name and location as the value.
Windows XP
- Start -> Control Panel -> System - > Advanced
- Click environment variables, under System Variables, locate
PATH
and click it. - Na edit windows, modify
PATH
by adding the class location to the value ofPATH
. If you don't have thePATH
item, you can choose to add a new variable and addPATH
as the class name and location as the value. - close the window.
Windows Vista
- right-click the My Computer icon
- choose Properties from the context menu
- click the Advanced tab (link Advanced System settings in Vista)
- in the edit windows, modify
PATH
by adding the class location to the value ofPATH
. If you don't have thePATH
item, you can choose to add a new variable and addPATH
as the class name and location as the value.