What opening a file from cmd actually does
Opening a file using cmd (Command Prompt on Windows) means telling your computer to launch a program or document by typing a text command instead of clicking an icon. When you type a command and press Enter, Windows finds the file you named and opens it with whatever program is set as the default for that file type — or with a program you specify in the command itself.
Most people never need to do this. You can open files the normal way: double-click them in File Explorer, or find them in your Documents folder. But there are situations where using cmd is faster or necessary — like when you're troubleshooting a problem, automating a task, or working on a computer where the graphical interface isn't working properly.
Key Takeaways
- Command Prompt is a text-based way to give your computer instructions; typing a filename and pressing Enter opens that file with its default program.
- The simplest command is just the filename itself — type notepad.exe or document.docx and press Enter — if the file is in the current folder or in a location Windows knows about.
- If the filename has spaces or special characters, you need to put the whole path in quotation marks, like "C:\Users\YourName\My Documents\my file.docx".
- You can also use the start command to open a file with a specific program, like start notepad "C:\path\to\file.txt".
- Command Prompt is most useful when you already have it open for other reasons, or when you're following troubleshooting steps that specifically ask you to use it.
How to open Command Prompt first
Before you can type any command, you need to have Command Prompt open on your screen. On Windows 10 or 11, press the Windows key (the one with the four squares) and type cmd. You'll see "Command Prompt" appear in the search results. Click it to open a black window with white text.
You can also right-click the Start button and select "Terminal" or "Command Prompt" from the menu. Once the window is open, you'll see a blinking cursor and a line that ends with > — that's where you type your commands.
The simplest way: just type the filename
If you want to open a file that's in the current folder (the folder Command Prompt is looking at right now), you can often just type the filename and press Enter. For example, if you have a file called notes.txt in the current folder, type:
notes.txt
Then press Enter. Windows will open that file with whatever program is set as the default for .txt files — usually Notepad.
This works for any file type: photo.jpg opens in your default image viewer, document.docx opens in Word or a compatible program, spreadsheet.xlsx opens in Excel. The catch is that the file has to be in the folder Command Prompt is currently looking at. If it's not, you'll get an error message saying the file was not found.
Opening files in other folders: the full path
Most of the time, the file you want to open is not in the current folder. You need to tell Command Prompt where to find it by typing the full path — the complete address of the file on your computer, starting from the drive letter.
For example, if you have a file called budget.xlsx in your Documents folder, the full path might look like this:
C:\Users\YourName\Documents\budget.xlsx
Type that entire line and press Enter. Windows will open the file. The C: at the start means the C drive (your main hard drive). The backslashes separate the folder names. YourName is your Windows username.
If the filename or any folder name has spaces in it, you must put the entire path in quotation marks, like this:
"C:\Users\Your Name\My Documents\my budget.xlsx"
Without the quotation marks, Command Prompt will think the space means the end of the command and will give you an error.
Using the start command to pick which program opens the file
Normally, Windows opens a file with whatever program you've set as the default. But sometimes you want to open a file with a different program. That's where the start command comes in.
The basic format is:
start [program name] "[file path]"
For example, if you want to open a text file with Notepad specifically, you'd type:
start notepad "C:\Users\YourName\Documents\notes.txt"
Or if you want to open an image with Paint:
start mspaint "C:\Users\YourName\Pictures\photo.jpg"
The program name (like notepad or mspaint) is the executable file — the actual program file itself. Common ones include notepad for text editing, mspaint for image editing, calc for the calculator, and explorer to open a folder in File Explorer.
When you'd actually use this instead of just clicking
In everyday use, opening files by clicking is faster and easier than typing commands. But there are real situations where cmd is the better choice.
If you're following troubleshooting steps from a tech support article or from someone helping you fix a problem, they might ask you to open a file from Command Prompt. This is often because the graphical interface isn't working, or because they need you to open a system file that's hidden from normal view.
If you're writing a batch file — a text file that contains multiple commands that run one after another — you'd use these commands to open files as part of an automated process. For example, a batch file might open a log file, check its contents, and then open a report based on what it found.
If Command Prompt is already open because you're doing other command-line work, typing a filename is sometimes faster than minimizing the window, finding the file in File Explorer, and double-clicking it.
Common mistakes and what they mean
If you type a command and see '[filename]' is not recognized as an internal or external command, it means Command Prompt couldn't find the file or program you named. This usually happens because the file is not in the current folder, or the path is typed incorrectly. Double-check the spelling and make sure you've included the full path with quotation marks if there are spaces.
If you see The system cannot find the file specified, the path you typed doesn't exist. Verify the folder names and the filename are correct. You can also type dir and press Enter to see a list of files in the current folder, which helps you check spelling.
If a file opens but nothing happens, the program might be running in the background. Try clicking the taskbar at the bottom of your screen to see if a new window appeared there, or wait a few seconds for the program to load.
Frequently Asked Questions
Do I need to type the .exe extension when opening a program?
No. You can type notepad instead of notepad.exe, and Windows will find the program. However, typing the full name with .exe also works. For files like documents, you do need the extension — type document.docx, not just document.
What's the difference between cmd and PowerShell?
PowerShell is a newer, more powerful version of Command Prompt that can do more complex tasks. For opening files, both work the same way. If you're following instructions that say to use cmd, use Command Prompt. If they say PowerShell, use that instead. On Windows 11, PowerShell is becoming the default.
How do I find the full path to a file if I don't know it?
Open File Explorer, find the file, right-click it, and select "Copy as path." Then paste it into Command Prompt. This copies the full path with quotation marks already included, so you don't have to type it manually.
Can I open a file from a USB drive or external hard drive?
Yes. External drives show up as different drive letters — often D:, E:, or F: depending on how many drives you have. Type the full path starting with the correct drive letter, like "E:\folder\filename.txt".