How to Open a File in Command Prompt (Windows Guide)

Command Prompt gives you direct, text-based control over your Windows system — including the ability to open files without ever touching the desktop or File Explorer. Whether you're troubleshooting, scripting, or just prefer working in a terminal, knowing how to open files from the command line is a genuinely useful skill.

What "Opening a File" Actually Means in Command Prompt

When you double-click a file in Windows, the operating system checks the file's extension, finds the associated program, and launches it. Command Prompt can replicate that exact behavior — or go further, letting you specify which application opens the file, pass arguments, or run scripts directly.

There are two distinct approaches:

  • Launching a file with its default program — the equivalent of double-clicking
  • Opening a file with a specific application — you choose the program explicitly

Understanding this distinction matters because the commands you use are different depending on your goal.

Method 1: Use the start Command to Open Any File

The start command tells Windows to open a file using whatever program is associated with its extension — just like double-clicking.

start filename.ext 

Example:

start report.pdf 

This opens report.pdf in your default PDF reader. The same logic applies to .docx, .mp3, .jpg, .xlsx, or any other file type — as long as a default program is assigned.

If the file is not in your current directory, you need to include the full path:

start "C:UsersYourNameDocuments eport.pdf" 

💡 Why the quotes? If a file path contains spaces (which is common in Windows), wrapping it in quotation marks tells Command Prompt to treat the whole string as a single path rather than separate arguments.

Method 2: Open a File With a Specific Application

If you want to override the default program — or if no default is set — you can call the application directly, followed by the file path.

Syntax:

"C:PathToApplication.exe" "C:PathToFile.ext" 

Example — opening a text file in Notepad:

notepad "C:UsersYourNameDocuments otes.txt" 

Example — opening a file in a specific browser:

"C:Program FilesGoogleChromeApplicationchrome.exe" "C:UsersYourNameindex.html" 

This approach is especially useful when you have multiple versions of an application installed, or when you want to automate a workflow through a batch script.

Method 3: Run Executable and Script Files Directly

For .exe, .bat, .cmd, and .py files, you can run them by typing their name (or full path) directly into the prompt.

myprogram.exe 

or

C:Scriptsackup.bat 

For Python scripts, if Python is installed and added to your system PATH:

python myscript.py 

The PATH variable determines which commands Command Prompt can find without a full file path. If a program isn't in PATH, you'll either need to navigate to its directory first or type the full path to the executable.

Navigating to the Right Directory First

Before running any of these commands, Command Prompt needs to be pointed at the right location — or you need to specify full paths. The cd command changes your current directory.

cd C:UsersYourNameDocuments 

Once inside that folder, you can reference files by name alone without typing the full path every time.

Useful navigation shortcuts:

CommandWhat It Does
cd FolderNameMove into a subfolder
cd ..Move up one level
cd /d D:FilesSwitch to a different drive entirely
dirList all files in the current directory

Variables That Affect How This Works

Not every user will get identical results with the same commands, because several factors shape the experience:

File associations — If a file type has no default program assigned in Windows, start may throw an error or open an "Open With" dialog rather than launching silently. This is common with less common file extensions.

User permissions — Opening certain files (especially in system directories) may require running Command Prompt as Administrator. Right-clicking the Command Prompt icon and selecting "Run as administrator" elevates your privileges.

PATH configuration — Whether you can call an application by its short name (like notepad or python) depends on whether that application's folder is registered in your system's PATH environment variable. Advanced users often customize this; default installations vary by software.

Windows version — The core commands (start, cd, dir) work consistently across Windows 10 and Windows 11, but the default application ecosystem and how file associations are managed can differ slightly between versions.

File location and naming — Spaces, special characters, and deeply nested paths all affect how you need to write your commands. Quotation marks solve most spacing issues, but some special characters require escaping.

🖥️ What Changes Between User Setups

A developer running Windows 11 with Python, Node.js, and VS Code all in PATH has a very different experience than a standard home user on Windows 10 with default software. The former can open almost any file with short, clean commands. The latter may need to look up full application paths or set up associations first.

Similarly, IT professionals writing batch scripts to open files across a network share will need to handle UNC paths (like \ServerSharefile.txt) and permission structures that don't apply at all to someone just opening a local document.

The commands themselves are consistent — but how smoothly they run, and how much setup they require, depends entirely on what's already configured on a given machine.