Opening a file from command prompt means typing a command that tells your computer to launch the file with its default program
The command prompt is a text-based way to control your computer by typing instructions instead of clicking. When you open a file from command prompt, you are not using File Explorer or double-clicking — you are typing a line that says "open this file now." The file then opens in whatever program your computer has set as the default for that file type.
This is useful when you need to open a file that is buried several folders deep, when you want to open many files at once, or when the normal clicking method is not working. The basic approach is the same on Windows and Mac, though the exact commands differ slightly.
Key Takeaways
- On Windows, type start filename.ext to open a file with its default program, or start /d "folder path" filename.ext if the file is in a different folder.
- On Mac, type open filename.ext to open a file, or open -a "Program Name" filename.ext to open it with a specific program.
- You must be in the same folder as the file, or you must type the full path to the file, or the command will not find it.
- If a filename or folder name has spaces in it, you must put the entire path in quotation marks so the command prompt understands it as one thing.
Opening a file on Windows using the start command
On Windows, the command to open a file is start followed by the filename. Open Command Prompt by pressing the Windows key, typing "cmd", and pressing Enter. You will see a black window with a blinking cursor.
If the file you want to open is in the same folder where command prompt opened, type start document.docx (replacing "document.docx" with your actual filename) and press Enter. The file will open in Word or whatever program handles .docx files on your computer. If you want to open a different file type — a photo, a PDF, a spreadsheet — use the same command with that filename instead.
If the file is in a different folder, you need to tell command prompt where to find it. Type start "C:\Users\YourName\Documents\document.docx", replacing the path with the actual location of your file. The quotation marks tell command prompt to treat the whole path as one instruction. Press Enter and the file opens.
Opening a file on Mac using the open command
On Mac, the command to open a file is open followed by the filename. Open Terminal by pressing Command and Space together, typing "terminal", and pressing Enter. You will see a window with a blinking cursor and your username.
If the file is in the same folder, type open document.docx and press Enter. The file opens in its default program. If the file is in a different folder, type the full path: open /Users/YourName/Documents/document.docx. On Mac, paths start with a forward slash, not a backslash like Windows.
If you want to open the file with a specific program instead of the default one, type open -a "Program Name" document.docx. For example, open -a "TextEdit" document.docx will open the file in TextEdit even if Word is the default. The program name must be in quotation marks.
Handling filenames and paths with spaces
If your filename or any folder in the path has a space in it, command prompt will misunderstand the command unless you use quotation marks. For example, if your file is called "My Document.docx", typing start My Document.docx will not work because command prompt thinks "My" is the filename and "Document.docx" is a separate instruction.
Instead, type start "My Document.docx" with quotation marks around the entire filename. The same rule applies to folder paths: if a folder is called "My Folder", type start "C:\Users\YourName\My Folder\My Document.docx" with quotation marks around the whole path.
Finding the full path to a file
If you do not know the full path to your file, you can find it by opening File Explorer (Windows) or Finder (Mac) and locating the file. On Windows, right-click the file and select "Properties". Look for the "Location" field — this is the folder path. Copy it, then type the path into command prompt with the filename at the end.
On Mac, right-click the file and select "Get Info". Look for the "Where" field to see the full path. You can also drag the file directly into Terminal and it will type the path for you automatically.
Opening multiple files at once
You can open several files in one command by typing each filename after the start or open command, separated by spaces. On Windows, type start file1.docx file2.docx file3.docx and press Enter. Each file will open in its default program. On Mac, type open file1.docx file2.docx file3.docx.
If any filename has spaces, put quotation marks around that filename only: start "My Document.docx" other.docx. This method works best when all the files are in the same folder as where command prompt is currently running.
Troubleshooting when the file will not open
If you type the command and nothing happens, the most common reason is that command prompt cannot find the file. Check that you spelled the filename correctly, including the file extension (.docx, .pdf, .jpg, and so on). If the file is in a different folder, make sure you typed the full path correctly. On Windows, use backslashes in paths. On Mac, use forward slashes.
If you get an error message saying the file type is not recognized, it means no program on your computer is set as the default for that file type. You can still open it by specifying the program: on Windows, type start /d "C:\Program Files\Program Name" filename.ext, replacing "Program Name" with the actual program folder. On Mac, use the open -a command shown earlier.
Frequently Asked Questions
Do I have to be in the same folder as the file?
No. If the file is in a different folder, type the full path to the file instead of just the filename. On Windows, paths look like C:\Users\YourName\Documents\filename.ext. On Mac, paths look like /Users/YourName/Documents/filename.ext. If you do not know the full path, use File Explorer or Finder to find the file and copy its location.
What if the filename has special characters like parentheses or ampersands?
Put the entire filename in quotation marks. For example, start "Report (Final).docx" on Windows or open "Report (Final).docx" on Mac. Quotation marks tell command prompt to treat everything inside as part of the filename, not as separate instructions.
Can I open a file with a program that is not the default?
Yes. On Windows, use start /d "Program Folder" filename.ext or type the full path to the program's .exe file. On Mac, use open -a "Program Name" filename.ext. The program name must match exactly what appears in your Applications folder.
What if I want to open a file but I am not sure of the exact filename?
Type the first few letters of the filename, then press Tab. Command prompt will try to complete the filename for you. If it shows the wrong file, press Tab again to cycle through other files that start with those letters. This only works if you are in the same folder as the file.
Does this method work for all file types?
Yes, as long as your computer has a program that can open the file type. If you try to open a file type that has no associated program, you will get an error. You can then specify which program to use with the methods described above.