CMD Simulator
System Informationpath

PATH Command – Display or Set the PATH Environment Variable in Windows

Learn how to use the PATH command to view or change the search path for executables in Windows Command Prompt. Syntax, examples, and best practices for PATH management.

Rojan Acharya··Updated Mar 15, 2026
Share

The PATH command is a Windows Command Prompt utility that displays or sets the PATH environment variable—the list of directories Windows searches when you run a command by name. Use PATH with no arguments to show the current PATH, or PATH [value] to set it for the current session (e.g. add a folder so you can run executables without typing the full path).

Whether you're adding a development tool to PATH, troubleshooting "not recognized" errors, or writing scripts that depend on specific search paths, understanding PATH is essential for command-line and automation workflows.

This guide covers PATH syntax, displaying vs setting PATH, common examples, tips, and frequently asked questions.

What Is the PATH Command?

PATH (the command) controls the PATH environment variable. That variable is a semicolon-separated list of directories. When you type a command name (e.g. node, python), Windows looks in each directory in PATH, in order, for an executable with that name. The PATH command lets you view or change this list for the current CMD session without opening System Properties.

The PATH command is available in Command Prompt (CMD) on all modern Windows versions. Changes made with PATH apply only to the current window and any processes started from it; they do not permanently change the user or system PATH (use System Environment Variables or setx for that).

PATH Command Syntax

PATH
PATH ;
PATH [[drive:]path[;...]]
  • PATH (no arguments) – Displays the current PATH.
  • PATH ; – Clears the current session PATH (rarely used).
  • PATH value – Sets PATH to the given value (replaces the current session PATH). Multiple directories are separated by semicolons (;).

Parameters

UsageDescription
(no args)Display current PATH.
;Clear PATH for current session.
[drive:]path[;...]Set PATH to the given list of directories.

Setting PATH replaces the entire session PATH; it does not append. To add a directory, you typically use: PATH %PATH%;C:\NewFolder.

Examples

Display current PATH

PATH

Output is one line: PATH=drive:\path1;drive:\path2;...

Set PATH to a single directory (replace session PATH)

PATH C:\Tools

After this, only C:\Tools is in the search path for that CMD window. Previous PATH entries are no longer used in this session.

Append a directory to the current PATH

PATH %PATH%;C:\MyApp\bin

This keeps existing PATH and adds C:\MyApp\bin at the end. Use this pattern to temporarily add a folder for the current session.

Prepend a directory (higher priority)

PATH C:\PriorityTool;%PATH%

The new directory is searched first. Useful when you want to override a tool that exists in another PATH folder.

Clear PATH for current session

PATH ;

PATH is cleared. Most commands that are not built-ins (e.g. dir, cd) will then show "not recognized" until you set PATH again or open a new CMD that inherits the system/user PATH.

Common Use Cases

  1. Running a tool without full path – Add the tool’s folder to PATH (e.g. PATH %PATH%;C:\Node) so you can run node from anywhere.
  2. Troubleshooting "not recognized" – Run PATH to see current search path; add the folder that contains the executable if missing.
  3. Scripts – Set or extend PATH at the start of a batch file so subsequent commands find the right executables.
  4. Temporary override – Prepend a directory to PATH to use a different version of a tool for one session.

Tips and Best Practices

  1. Session-only – PATH command changes apply only to the current CMD session. For permanent changes use System Properties → Environment Variables or setx PATH "value" (with care).
  2. Use %PATH% when appending – Always include %PATH% when you want to add rather than replace: PATH %PATH%;C:\NewPath.
  3. Semicolons – Separate directories with ; (no spaces around semicolons in typical usage).
  4. Long paths – Very long PATH values can cause issues; keep the list manageable and remove obsolete entries.

Troubleshooting

Command still "not recognized" after setting PATH

  • Ensure the directory you added actually contains the executable (e.g. node.exe).
  • Restart CMD after permanent PATH changes; session changes take effect immediately in that window.
  • Check for typos in the path and that you used %PATH% when appending.

PATH is too long

Windows has limits on environment variable length. Shorten PATH by removing unused entries or using shorter paths (e.g. C:\Prog instead of C:\Program Files\...).

Related Commands

  • SET – Display or set environment variables (e.g. SET PATH= or SET MYVAR=value).
  • SETX – Set user or system environment variables persistently (outside the current session).
  • ECHO %PATH% – Another way to display PATH (ECHO shows the expanded value).

Frequently Asked Questions

What does the PATH command do?

It displays the current PATH (with no arguments) or sets the PATH for the current CMD session (with a value). It does not by default change the permanent user or system PATH.

How do I add a folder to PATH permanently?

Use System Properties → Advanced → Environment Variables, or setx PATH "%PATH%;C:\NewFolder" from an elevated or user context. Be careful with setx as it uses the current session’s PATH value; document the change or use the GUI for safety.

Why does PATH ; clear everything?

PATH ; sets PATH to an empty value (the semicolon alone is treated as "no directories"). So the search path for that session becomes empty.

Can I have spaces in PATH entries?

Yes. Paths with spaces do not require quotes when set via the PATH command (e.g. PATH %PATH%;C:\Program Files\MyApp). In batch files, quoting can help: PATH "%PATH%;C:\Program Files\MyApp".

Quick Reference Card

CommandPurposeExample
PATHDisplay current PATHPATH
PATH valueSet PATH for sessionPATH C:\Tools
PATH %PATH%;dirAppend directoryPATH %PATH%;C:\MyApp
PATH ;Clear session PATHPATH ;

Summary

The PATH command shows or sets the search path for executables in the current CMD session. Use it to inspect PATH, temporarily add or override directories, or clear the path. For permanent changes, use System Environment Variables or SETX with care.

Practice PATH in the Windows Command Simulator. See the Commands Reference for SET, SETX, and other environment and system commands.