PATH is an environment variable that specifies a set of directories, separated with semicolons (
;), where executable programs are located.
In this note i am showing how to print the contents of Windows
PATH environment variable from the Windows command prompt.
I am also showing how to add a directory to Windows
PATH permanently or for the current session only.
Cool Tip: List environment variables in Windows! Read More →
Echo Windows PATH Variable
Print the contents of the Windows
PATH variable from
– or –
C:\> echo %PATH%
The above commands return all directories in Windows
PATH environment variable on a single line separated with semicolons (
;) that is not very readable.
To print each entry of Windows
PATH variable on a new line, execute:
C:\> echo %PATH:;=&echo.%
Cool Tip: Set environment variables in Windows! Read More →
Add To Windows PATH
Warning! This solution may be destructive as Windows truncates
PATH to 1024 characters. Make a backup of
PATH before any modifications.
Save the contents of the Windows
PATH environment variable to
C:\> echo %PATH% > C:\path-backup.txt
Set Windows PATH For The Current Session
PATH variable for the current session:
C:\> set "%PATH%;C:\path\to\directory\"
Set Windows PATH Permanently
Run as Administrator: The
setx command is only available starting from Windows 7 and requires elevated command prompt.
Permanently add a directory to the user
C:\> setx path "%PATH%;C:\path\to\directory\"
Permanently add a directory to the system
PATH variable (for all users):
C:\> setx /M path "%PATH%;C:\path\to\directory\"
Info: To see the changes after running
setx – open a new command prompt.