The basic command to open a file in Command Prompt

To open a file in Command Prompt, type the full path to the file after a command that tells Windows what to do with it. The simplest approach is to type the filename directly if you're already in the folder where it lives, or use the full path if you're elsewhere. For example, if you have a text file called notes.txt in your Documents folder, you can open it by typing notepad C:\Users\YourUsername\Documents\notes.txt and pressing Enter.

The command you use depends on what kind of file you're opening. Text files open with notepad, Word documents with start, PDFs with start, and so on. The start command is the most flexible — it tells Windows to open the file with whatever program is set as the default for that file type.

Key Takeaways

  • Use start followed by the file path to open any file with its default program, like start C:\Users\YourUsername\Documents\report.pdf.
  • Use notepad to open text files directly in Notepad, or notepad filename.txt to create and open a new file at the same time.
  • If you're in the same folder as the file, you can type just the filename instead of the full path.
  • File paths with spaces in the folder names need to be wrapped in quotation marks, like start "C:\Program Files\My App\document.docx".
  • You can open multiple files at once by listing them one after another, like start file1.txt file2.txt.

Understanding file paths in Command Prompt

A file path is the address that tells Command Prompt where to find your file. It starts with the drive letter (usually C:), then lists each folder separated by backslashes, and ends with the filename. For example, C:\Users\YourUsername\Documents\budget.xlsx means "on the C drive, in the Users folder, in the YourUsername folder, in the Documents folder, find the file called budget.xlsx".

You can find the full path to any file by opening File Explorer, right-clicking the file, selecting Properties, and looking at the "Location" field. Copy that location, add a backslash, and then add the filename. If the path contains spaces — like C:\Program Files\My Documents\file.txt — wrap the entire path in quotation marks when you type it into Command Prompt.

Using the start command for any file type

The start command is the most reliable way to open files because it uses Windows' default settings. When you type start filename.pdf, Windows opens the PDF with whatever program you've set as your default PDF viewer. This works for Word documents, Excel spreadsheets, images, videos, and almost any other file type.

If you want to open a file with a specific program instead of the default, you can tell Command Prompt which one to use. For example, start notepad myfile.txt opens the file in Notepad even if your default text editor is something else. You can also use start "" "C:\Program Files\Application Name\app.exe" "C:\path\to\file.txt" to open a file with a specific application — the empty quotation marks after start are required when you're specifying a program.

Opening text files with notepad

Notepad is built into Windows and opens instantly from Command Prompt. Type notepad filename.txt to open an existing text file, or type the same command with a filename that doesn't exist yet and Notepad will create a new blank file with that name. This is faster than using the start command if you know you want Notepad specifically.

You can also use notepad by itself with no filename to open a blank Notepad window. This is useful if you want to create a new file and save it later. When you're done editing, close Notepad normally and Command Prompt will return to the prompt, ready for your next command.

Navigating to the file's folder first

If you're opening files in the same folder repeatedly, you can navigate to that folder in Command Prompt first, then type just the filename instead of the full path. Use the cd command to change directories. For example, cd C:\Users\YourUsername\Documents moves you into your Documents folder. After that, you can type start budget.xlsx instead of the full path.

To see what files are in your current folder, type dir and press Enter. This shows you the exact filenames, which is helpful if you're not sure of the spelling or extension. You can also type cd .. to move up one folder level, or cd \ to jump back to the root of the drive.

Handling filenames with spaces and special characters

If a filename or folder name contains spaces, Command Prompt needs quotation marks around the path so it knows the whole thing is one address, not multiple commands. For example, start "C:\Users\John Smith\My Documents\Budget Report.xlsx" works, but start C:\Users\John Smith\My Documents\Budget Report.xlsx fails because Command Prompt sees "John" and "Smith" as separate items.

Special characters like parentheses, ampersands, and percent signs can also cause problems. The safest approach is to wrap any path with spaces or unusual characters in quotation marks. If you're still getting errors, try renaming the file or folder to remove spaces — use underscores or hyphens instead — and try again.

Frequently Asked Questions

What do I do if Command Prompt says "file not found"?

This usually means the path is wrong or the file doesn't exist. Double-check the spelling of the filename and folder names. Use dir to list files in your current folder, or navigate to the folder where the file actually is using cd. If the path has spaces, make sure it's wrapped in quotation marks.

Can I open a file that's on a different drive?

Yes. Type the drive letter first, like start D:\folder\filename.txt if the file is on your D drive. You can also type just the drive letter (like D:) and press Enter to switch to that drive, then navigate from there.

How do I open a file with a program that's not the default?

Use the full path to the program. For example, start "C:\Program Files\Notepad++\notepad++.exe" "C:\Users\YourUsername\file.txt" opens the file in Notepad++ instead of the default editor. The empty quotation marks after start are required.

What's the difference between start and just typing the filename?

Typing just the filename (like document.txt) only works if the file is a program or batch file in your current folder. For regular files like documents or images, you need start to tell Windows to open them with the right program.