Set Up Windows PATH and Environment Variables for Command-Line Tools
Difficulty: Beginner | Time Required: 15 minutesIf you have ever installed a command-line tool such as Git, Python, Node.js, Java, FFmpeg, ADB, or a compiler and then seen an error like:
'python' is not recognized as an internal or external commandWindows is telling you it cannot find that program from your current command prompt or terminal session. This is usually because the tool’s folder has not been added to the Windows
PATH environment variable.The
PATH variable is a list of folders that Windows checks when you type a command. By setting it correctly, you can run tools from Command Prompt, PowerShell, Windows Terminal, scripts, build tools, and development environments without typing the full folder path every time.This tutorial explains how to view, edit, and safely configure Windows environment variables, especially
PATH, on Windows 10 and Windows 11.Prerequisites
Before you begin, you should have:- A Windows 10 or Windows 11 PC.
- A user account with permission to edit environment variables.
- The command-line tool already installed, or at least know the folder path where its executable file is located.
Code:
C:\Program Files\Git\cmd
C:\Program Files\nodejs
C:\Python312
C:\Users\YourName\AppData\Local\Programs\Python\Python312
C:\ffmpeg\bin
Tip: The folder you add toPATHshould usually be the folder containing the.exefile, not the.exefile itself.
Understanding User vs System Environment Variables
Windows has two main levels of environment variables:- User variables
These apply only to your Windows account. - System variables
These apply to all users on the PC.
Use System PATH only when:
- The tool should be available to every user on the PC.
- You are setting up a shared development machine.
- The installer or documentation specifically requires it.
- You understand the impact of changing system-wide settings.
Warning: Be careful when editingPATH. Removing existing entries can break installed applications or development tools.
Step 1: Find the Tool’s Installation Folder
First, locate the folder containing the command-line program.For example, if you installed Git, the executable might be in:
C:\Program Files\Git\cmdIf you installed FFmpeg manually, it might be in:
C:\ffmpeg\binIf you are not sure where the program is installed:
- Open the Start menu.
- Search for the program name.
- Right-click it and choose Open file location.
- If it opens a shortcut, right-click the shortcut and choose Properties.
- Look at the Target field to identify the actual install location.
Code:
python.exe
git.exe
node.exe
ffmpeg.exe
adb.exe
For example, use this:
C:\ffmpeg\binNot this:
C:\ffmpeg\bin\ffmpeg.exeStep 2: Open Environment Variables Settings
The steps are almost identical on Windows 10 and Windows 11.Method 1: Using Start Search
- Open the Start menu.
- Type:
environment variables - Select Edit the system environment variables.
- In the System Properties window, select the Advanced tab.
- Click Environment Variables.
Method 2: Using Run
- Press Windows + R.
- Type:
sysdm.cpl - Press Enter.
- Go to the Advanced tab.
- Click Environment Variables.
- User variables for your account
- System variables
Step 3: Edit the User PATH Variable
For most command-line tools, edit the User PATH.- Under User variables, select
Path. - Click Edit.
- In the Edit Environment Variable window, click New.
- Paste the folder path for your tool.
C:\ffmpeg\bin- Click OK.
- Click OK again to close Environment Variables.
- Click OK to close System Properties.
Note: On modern Windows 10 and Windows 11 versions, thePatheditor displays each folder on its own line. On very old Windows versions, it may appear as one long text field separated by semicolons. Windows 10 and 11 users generally get the easier line-by-line editor.
Step 4: Open a New Terminal Window
Environment variable changes do not always apply to already-open terminal windows.Close any existing Command Prompt, PowerShell, or Windows Terminal sessions. Then open a new one.
You can test from any of these:
- Command Prompt
- PowerShell
- Windows Terminal
- Developer Command Prompt, if applicable
- Press Windows + R.
- Type:
cmd - Press Enter.
- Right-click Start.
- Choose Terminal or Windows PowerShell.
Step 5: Test the Command
Now test whether Windows can find the tool.For example:
git --versionpython --versionnode --versionffmpeg -versionIf everything is configured correctly, you should see version information instead of an error message.
Example:
Python 3.12.2or:
git version 2.45.0.windows.1If the command works, your
PATH setup is complete.Step 6: Add Other Environment Variables If Needed
Some tools require more than justPATH. They may also need a separate environment variable that points to an installation folder.Common examples include:
Code:
JAVA_HOME
ANDROID_HOME
ANDROID_SDK_ROOT
GOPATH
JAVA_HOME.To create a new user environment variable:
- Open Environment Variables again.
- Under User variables, click New.
- In Variable name, enter:
JAVA_HOME - In Variable value, enter the Java installation folder, such as:
C:\Program Files\Java\jdk-21 - Click OK.
bin folder to PATH, for example:%JAVA_HOME%\binThis allows commands such as:
Code:
java -version
javac -version
Tip: Using%JAVA_HOME%\bininPATHcan make future upgrades easier. If Java is later installed in a different folder, you can updateJAVA_HOMEinstead of changing multiple paths.
Step 7: Check Your PATH from the Command Line
You can view your currentPATH from Command Prompt with:echo %PATH%In PowerShell, use:
$env:PathThis can help confirm whether your folder appears in the active terminal session.
To find where Windows is resolving a command from, use:
where pythonor:
where gitPowerShell also supports:
Get-Command pythonThese commands are useful if you have multiple versions of the same tool installed.
Tips and Troubleshooting
The command still is not recognized
If you still see:is not recognized as an internal or external commandcheck the following:
- Did you open a new terminal window after editing
PATH? - Did you add the folder containing the
.exefile? - Did you accidentally add the
.exefile itself instead of the folder? - Is there a typo in the folder path?
- Does the folder still exist?
- Did you edit User PATH but run the terminal as a different user?
The wrong version is running
If a command works but launches the wrong version, Windows may be finding another copy earlier in thePATH.For example:
where pythonmay show multiple results:
Code:
C:\Users\YourName\AppData\Local\Microsoft\WindowsApps\python.exe
C:\Python312\python.exe
PATH entries in order. If needed, move the preferred folder higher in the list using the Move Up button in the Path editor.Warning: Do not randomly delete entries fromPATH. Move entries first when possible, and only remove paths you are sure are unnecessary.
PowerShell behaves differently than Command Prompt
PowerShell and Command Prompt both use environment variables, but their syntax differs.Command Prompt:
echo %PATH%PowerShell:
$env:PathIf testing a new command fails in one shell, close and reopen it. If you are using Windows Terminal, close the entire Windows Terminal window and open a fresh session.
Avoid extremely long or messy PATH entries
Over time,PATH can become cluttered with old software folders. This can make troubleshooting more difficult.Good practices include:
- Add only folders you actually need.
- Remove entries only when you are certain the software is gone.
- Avoid duplicate entries.
- Keep development tools organized in predictable locations.
Per-session changes are temporary
You may see commands online such as:Command Prompt:
set PATH=C:\Tools;%PATH%PowerShell:
$env:Path = "C:\Tools;$env:Path"These only affect the current terminal session. Once you close the window, the change is gone.
For permanent changes, use the Environment Variables window described above.
Conclusion
Setting upPATH and environment variables is one of the most useful beginner skills for working with command-line tools on Windows 10 and Windows 11. Once configured correctly, you can run tools like Git, Python, Node.js, Java, FFmpeg, and many others from any terminal window without navigating to their installation folders.A properly configured environment saves time, reduces errors, and makes your Windows PC much more comfortable for development, scripting, troubleshooting, and automation.
Key Takeaways:
PATHtells Windows where to look when you type a command.- Add the folder containing the tool’s
.exefile, not the.exeitself. - Use User PATH for most personal development tools.
- Open a new terminal after changing environment variables.
- Use
where commandnameorGet-Command commandnameto troubleshoot. - Be careful when editing or removing existing
PATHentries.
This tutorial was generated to help WindowsForum.com users get the most out of their Windows experience.