Path command

Updated: 11/12/2023 by Computer Hope
path command

The path command specifies the location where MS-DOS should look when it executes a command. For example, if you were to use the "format" command, the path must be specified, or you will receive the message "bad command or file name." See our path definition for a full explanation and examples of paths on computers.

Availability

Path is an internal command available in the following Microsoft operating systems.

Path syntax

Windows 10 and Windows 11 syntax

Displays or sets a search path for executable files.

PATH [[drive:]path[;...][;%PATH%]
PATH ;

Type PATH ; to clear all search-path settings and direct cmd.exe to search only in the current directory.
Type PATH without parameters to display the current path.
Including %PATH% in the new path setting causes the old path to be appended to the new setting.

Windows 8 and earlier syntax

Displays or sets a search path for executable files.

PATH [[drive:]path[;...]]
PATH ;

Type PATH ; to clear all directory names stored in your PATH variable. This command will force Windows to search only for command names you run in the current directory.

Path examples

path

Typing "path" by itself shows the current path information. Below is an example of the output you may receive when utilizing this command. As shown in the example below, multiple directories in the path are separated by a semicolon.

PATH=C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x8 6)\WinSCP;C:\Perl\site\bin;C:\Perl\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS \System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86 )\Windows Live\Shared;C:\Program Files (x86)\FAHClient;
path=c:\windows\command

The command above would set the path to C:\windows\command, where many of the Windows commands are located.

How do I set a path in a batch file?

To set or change the path in a batch file, use the path command, as shown above. For example, adding the above example of setting a new path would apply that path to your batch file and all future command-line commands.

Additional information

DOS limits the path to 122 bytes. Every command is limited to 127 bytes; however, 127 - 5 (minus 5 because of PATH=) = 122.