To set a path in Windows Command Prompt, type cd followed by the folder path to change the active directory. For system execution, update the PATH environment variable using setx (permanent) or set (temporary) so Windows can find your files from anywhere.
1. Set the Current Working Directory
To navigate to a specific folder where your files are located, use the cd (Change Directory) command.
cmd
cd "C:\Your\Folder\Path\Here"
Use code with caution.
- Pro Tip: If you want to switch to a folder on a different drive (e.g., from
C:toD:), simply type the drive letter and a colon, likeD:. - Shortcut: In File Explorer, navigate to your folder, click the address bar, type
cmd, and press Enter to instantly open a command prompt right there.
2. Add a Path for Global Executables
If you have a file or executable (like a .exe or .bat) that you want to run from any folder, you must add its location to your PATH environment variable.
Permanently for all Command Prompt sessions:
Use the setx command. Note that this requires Administrator privileges and the changes will take effect in newly opened Command Prompt windows.
cmd
setx PATH "%PATH%;C:\Your\Folder\Path\Here"
Use code with caution.
Temporarily for the current session:
Use the set command. This only lasts while your current command prompt window is open.
cmd
set PATH=%PATH%;C:\Your\Folder\Path\Here
Use code with caution.
3. Verify Your Path
To check if your directory has been added to the path successfully, run the following command: [1]
cmd
echo %PATH%
Use code with caution.
BEFORE ADDING PATH USE THIS WHERE.EXE EXAMPLE :
where.exe openssl
![]()