The basic command to open a file from cmd

To open a file from the 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 alone if you are already in the folder where the file lives, or the full path if you are somewhere else. Windows will open the file in whatever program is set as the default for that file type.

For example, if you have a document called report.docx in your Documents folder and you are already in that folder, you type report.docx and press Enter. If you are in a different folder, you type the full path: C:\Users\YourName\Documents\report.docx and press Enter.

The file opens in the program Windows has assigned to that file type — Word for .docx files, Notepad for .txt files, your default browser for .html files, and so on. This works for documents, images, videos, and most other file types you encounter.

Key Takeaways

  • Type the filename or full path at the command prompt and press Enter to open a file in its default program.
  • Use start before the filename to open a file and return control to the command prompt immediately instead of waiting.
  • Specify a different program by typing the program name followed by the file path, such as notepad C:\path\to\file.txt.
  • If the filename or path contains spaces, wrap the entire path in quotation marks so the command prompt reads it as one item.
  • Use cd to change to the folder where your file is stored, then type just the filename instead of the full path.

Using the start command to open files without waiting

When you type a filename and press Enter, the command prompt waits for the program to close before you can type another command. If you want to open a file and keep using the command prompt at the same time, use the start command before the filename.

Type start report.docx if you are in the same folder as the file, or start C:\Users\YourName\Documents\report.docx if you are elsewhere. The file opens in its default program, and the command prompt returns to you immediately so you can type the next command. This is especially useful when you are running multiple commands in sequence and do not want to wait for each file to close.

Opening a file with a specific program

Sometimes you want to open a file in a program other than the default. For instance, you might want to open a .txt file in Notepad instead of whatever program Windows has set as default, or open an image in Paint instead of your photo viewer.

Type the program name, then a space, then the file path. For example, notepad C:\Users\YourName\Documents\notes.txt opens the file in Notepad. Or mspaint C:\Users\YourName\Pictures\photo.jpg opens the image in Paint. The program name must be one that Windows recognizes — either a built-in program like notepad or mspaint, or a program that has been added to your system PATH so the command prompt can find it.

If the program is not in your PATH and you do not know where it is installed, use the full path to the program instead: C:\Program Files\ProgramName\program.exe C:\path\to\file.txt. This tells the command prompt exactly where to find the program and which file to open with it.

Handling filenames and paths with spaces

If your filename or folder name contains spaces, the command prompt will misread the command unless you wrap the path in quotation marks. For example, if your file is called My Report.docx and it is in a folder called My Documents, typing the path without quotes will confuse the command prompt.

Instead, type "C:\Users\YourName\My Documents\My Report.docx" with quotation marks around the entire path. The quotes tell the command prompt to treat the whole thing as a single item, spaces and all. This applies whether you are using the start command, specifying a different program, or just typing the filename alone.

Changing folders to make commands shorter

If you are opening many files from the same folder, you can use the cd command to change to that folder first, then type just the filename without the full path. This makes each command shorter and easier to type.

Type cd C:\Users\YourName\Documents and press Enter. The command prompt now shows you are in the Documents folder. From there, you can type report.docx and the file opens. You can type start another-file.docx and that file opens too. When you are done, type cd .. to go back to the parent folder, or type cd C:\ to go to the root of your drive.

Troubleshooting when a file will not open

If you type a command and nothing happens, or you see an error message, the most common cause is that the path is wrong or the file does not exist where you think it does. Check that you have spelled the filename correctly, including the file extension like .docx or .txt. Check that the folder path is correct — you can open File Explorer and copy the path from the address bar if you are not sure.

If you see a message like "is not recognized as an internal or external command", the program you are trying to use is not in your PATH. Use the full path to the program instead, or navigate to the folder where the program is installed and run it from there. If the file opens but in the wrong program, use the method in the "Opening a file with a specific program" section above to specify which program you want.

Frequently Asked Questions

What is the difference between typing a filename and using the start command?

Typing just the filename makes the command prompt wait for the program to close before you can type again. Using start before the filename opens the file and returns control to the command prompt immediately. Use start when you want to open multiple files or run other commands without waiting.

Can I open a file that is on a different drive, like D: instead of C:?

Yes. Type the full path including the drive letter, such as D:\folder\filename.txt. If you want to change to that drive first, type D: and press Enter, then use cd to navigate to the folder you need.

What do I do if the filename has special characters or symbols in it?

Wrap the entire path in quotation marks, the same way you would for spaces. For example, "C:\Users\YourName\Documents\file (1).txt" or "C:\Users\YourName\Documents\file&report.txt". The quotes protect the special characters from being misinterpreted by the command prompt.

How do I find the full path to a file if I do not know it?

Open File Explorer, find the file, right-click it, and select Properties. The location field shows you the folder path. Copy that path, add a backslash and the filename, and you have the full path to use in the command prompt.

Can I open multiple files at once from the command prompt?

Yes, use the start command before each filename. Type start file1.docx and press Enter, then start file2.docx and press Enter. Each file opens in its own window, and you can continue typing commands in the prompt.