Back to docs
Tools - ConfigurationUpdated: November 23, 2024

path

See or change the command search path.

path

Command: path

Category: Configuration

Type: CMD

Purpose

Displays or temporarily modifies the PATH environment variable, which tells Windows where to search for executable files when you type commands. Without proper PATH configuration, you'd need to specify full file paths for every command.

Quick Summary

A simple command to view or modify where Windows looks for executables. Type path alone to see the current search path, or use it to temporarily add directories for the current session. Essential for troubleshooting "command not found" errors and understanding command resolution.

How to Use

View current PATH:

path

Set new PATH (temporary, current session only):

path C:\Windows;C:\Windows\System32;C:\MyTools

Append to existing PATH (temporary):

path %PATH%;C:\NewFolder

Clear PATH (not recommended):

path ;

Tips and Best Practices

  • Use path alone to quickly verify your search paths.
  • Changes made with path are temporary and only affect the current Command Prompt session.
  • Multiple directories are separated by semicolons (;).
  • Order matters: Windows searches directories left to right and uses the first match.
  • To permanently modify PATH, use System Properties > Environment Variables or setx.
  • Common paths include: C:\Windows, C:\Windows\System32, Program Files directories.
  • If path shows too much, try: path > path.txt then open the file.

Common Use Cases

  • Troubleshooting commands: Verify that a program's directory is in the PATH when commands aren't recognized.
  • Temporary testing: Add a directory to PATH to test scripts or programs without permanent changes.
  • Path verification: Confirm that important directories are included in the search path.
  • Command resolution debugging: Understand which directory Windows will search first for executables.

Prerequisites

  • Windows Command Prompt (PATH works differently in PowerShell)
  • No administrator rights required to view or temporarily modify in current session
  • Administrator rights required for permanent system-wide changes

Important Notes

  • Temporary changes only: The path command only modifies the current session. Open a new Command Prompt window, and it reverts.
  • Don't clear PATH: Running path ; will clear the path, making most commands unusable in that session.
  • Case insensitive: Directory paths are case-insensitive in Windows.
  • Spaces in paths: Enclose paths containing spaces in quotes: path "C:\Program Files\MyApp";%PATH%

Setting PATH Permanently

Via GUI:

  1. Right-click "This PC" > Properties
  2. Click "Advanced system settings"
  3. Click "Environment Variables"
  4. Edit "Path" variable in User or System section
  5. Add new directories (one per line in Windows 10/11 editor)

Via Command (PowerShell or CMD as Admin):

setx PATH "%PATH%;C:\NewFolder" /M

Note: After using setx, close and reopen Command Prompt to see changes.

Troubleshooting

  • "Command not found" error - The executable isn't in any PATH directory; add its location to PATH or use the full file path.
  • Wrong version of program runs - Multiple versions may exist in PATH; the first one found is used. Check where command to see all matches.
  • PATH too long - Windows has character limits (~2048 characters); clean up unnecessary entries.
  • Changes don't persist - Use setx or the GUI for permanent modifications.
  • Accidentally cleared PATH - Close the Command Prompt and open a new one; it will restore the original PATH.

Find where a command is located:

where commandname

View PATH in easier format (PowerShell):

$env:Path -split ';'

See PATH from set command:

set PATH

Examples

Check current PATH:

path

Temporarily add folder:

path %PATH%;C:\Tools

Test if directory is in PATH:

echo %PATH% | findstr /I "C:\MyFolder"
  • set PATH - Alternative way to view or modify PATH
  • setx PATH - Permanently modify PATH from command line
  • where - Find which directory contains an executable
  • echo %PATH% - Display PATH variable value
  • PowerShell: $env:Path - View/modify PATH in PowerShell