Environment variables are small named values that Windows and programs consult to know where things are. This guide is for anyone installing command-line tools (Python, Git, Node, ffmpeg…) who hits the classic “is not recognized as an internal or external command”.
In short
- An environment variable is a name with a value, for example
TEMP= temporary folder.- PATH is the list of folders where Windows searches for the executables you type in the console.
- There are user variables (your account only) and system variables (all accounts, require administrator).
- To edit PATH use the graphical window or PowerShell; avoid
setx PATH, which can truncate it.- Changes are only seen in windows and programs opened after saving.
What an environment variable is
Think of them as named shortcuts. Instead of each program hard-coding your user folder path, it asks for USERPROFILE and Windows answers C:\Users\Ana.
Some that exist on any computer:
| Variable | Typical value | Used for |
|---|---|---|
USERPROFILE | C:\Users\Ana | User’s home folder |
APPDATA | C:\Users\Ana\AppData\Roaming | Program settings |
TEMP / TMP | C:\Users\Ana\AppData\Local\Temp | Temporary files |
SystemRoot | C:\Windows | Windows folder |
COMPUTERNAME | LIVINGROOM-PC | Computer name |
PATH | List of folders | Where to search for executables |
You can use them in File Explorer or in Run (Windows + R). Type %TEMP% and the temporary folder opens.
PATH explained with an example
When you type python in the console, Windows does not search the whole disk. It looks in the current folder first and then goes, in order, through each PATH folder until it finds python.exe (or .cmd, .bat…).

If PATH contains this:
C:\Windows\system32
C:\Windows
C:\Program Files\Git\cmd
C:\Users\Ana\AppData\Local\Programs\Python\Python313
typing git finds C:\Program Files\Git\cmd\git.exe in third position. If the Python folder were not in the list, python would fail even though installed.
Two practical consequences:
- Order matters. With two Python versions in PATH, the first one wins.
- The final PATH is the sum of two. Windows puts the system PATH first and appends the user one.
To see which executable is actually used:
where python
In PowerShell, the equivalent is:
Get-Command python | Select-Object Source
User variables versus system variables

| User | System | |
|---|---|---|
| Affect | Only your account | All accounts on the PC |
| Permissions | Yours | Administrator |
| Where stored | HKEY_CURRENT_USER\Environment | HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment |
| When to use | Tools only you use | Shared software or services |
Simple rule: when in doubt, use the user one. It is harder to break something and you need no elevated permissions.
Method 1: edit with the graphical window
The safest method, especially for PATH, since each folder appears on its own row.
- Press Start and type
environment variables. - Choose Edit the system environment variables. System Properties opens on the Advanced tab.
- Click Environment Variables…
- User variables are at the top; system variables at the bottom.
- Select
Pathin the area you want and click Edit… - Click New, paste the folder path (not the
.exe) and use Move Up or Move Down to place it. - Click OK in all windows.
To edit only your user ones, you can also open that window directly from Run (Windows + R):
rundll32 sysdm.cpl,EditEnvironmentVariables
Method 2: setx from the console
setx saves variables permanently from Command Prompt. By default it writes user variables; with /m, system ones (open the console as administrator).
setx JAVA_HOME "C:\Program Files\Java\jdk-21"
setx JAVA_HOME "C:\Program Files\Java\jdk-21" /m
According to Microsoft’s documentation, setx has two behaviors worth knowing:
- The new value only appears in windows opened afterward, not the current one.
- There is a 1024-character limit. Beyond it, the text is truncated and that is what gets saved.
Why not use setx with PATH
The most repeated mistake in tutorials:
:: Do NOT do this
setx PATH "%PATH%;C:\tools"

%PATH% contains the system and user PATH already combined. That command copies everything into the user PATH, duplicates entries and, if the string exceeds 1024 characters, truncates it. It also expands references like %JAVA_HOME%, which stop updating on their own.
For simple variables setx is fine. For PATH, use the graphical window or PowerShell.
Method 3: PowerShell
PowerShell distinguishes between the current session and permanent values.
See or change a variable only in the open window (lost on close):
$env:PATH
$env:MY_VARIABLE = "hello"
Save a variable permanently for your user:
[Environment]::SetEnvironmentVariable("MY_VARIABLE", "hello", "User")
With "Machine" instead of "User" it is saved as a system one (PowerShell as administrator).
Add a folder to the user PATH without wrecking it
$folder = "C:\tools"
$current = [Environment]::GetEnvironmentVariable("Path", "User")
if (($current -split ";") -notcontains $folder) {
[Environment]::SetEnvironmentVariable("Path", "$current;$folder", "User")
}
This script reads only the user PATH, checks the folder is not already there and appends it. It does not touch the system PATH.
Practical example: portable ffmpeg
You unzipped ffmpeg to C:\tools\ffmpeg\bin and want to use it from any folder.
- Open the environment variables window (method 1).
- Under user variables, edit
Pathand addC:\tools\ffmpeg\bin. - Close all open consoles and open a new one.
- Check:
where ffmpeg
ffmpeg -version
If where returns the right path, you are done.
Common mistakes
- Adding the file path instead of the folder. PATH holds folders:
C:\tools\ffmpeg\bin, not...\bin\ffmpeg.exe. - Not restarting the console. Open windows keep the environment they started with. Same for editors like VS Code: close them completely.
- Quotes inside PATH. Not needed in the graphical window, even with spaces in the path.
- Two versions of the same program. Use
whereto see which wins and reorder entries. - Deleting the system PATH by accident. Before touching it, copy its value to a text file. In PowerShell:
[Environment]::GetEnvironmentVariable("Path", "Machine") | Out-File "$env:USERPROFILE\Desktop\system-path.txt"
Frequently asked questions
Do I need to restart Windows?
Usually not. Closing and reopening the programs or consoles that need the change is enough. Some system services do need a restart to read new system variables.
Is it case-sensitive?
No. Path, PATH and path are the same variable in Windows.
How do I see all variables?
In Command Prompt, set with no arguments. In PowerShell:
Get-ChildItem Env:



