How to Open a File from CMD in 4 Different Ways

5 mins read

Updated on 2026-10-19 19:09:12 to Windows Fix

Command Prompt (CMD) lets you open files without navigating through File Explorer. The command you need depends on the file's location and how you want to open it. This guide explains how to open a file from cmd and troubleshoot common problems, including files that are missing or won't open.

how to open a file from cmd

How to Open a File from CMD

The start command opens a file with its default application, while other commands let you choose a program or access a file's location. The examples below show how to use cmd to open a file in common situations.

1 Open a File with Its Default Application

To get started, use the following steps to open a file with its default application.

  • Press Win + R, type cmd, and press Enter to open Command Prompt.

  • Enter the following command, replacing the example path with your file's actual location:

    start "" "C:\Files\report.pdf"

    open a file with default application with cmd
  • Press Enter. Windows opens the PDF in its default viewer or browser.

The empty quotation marks after start represent the window title, so CMD treats the quoted path as the target. Keep file paths in double quotes, especially when they contain spaces.

2 Open a File from a Specific Folder

You can switch to the folder containing your file before opening it. The cd command changes the current directory.

For example, to open a text file in your Documents folder:

cd /d "C:\Users\John\Documents" start "" "notes.txt"

open a file from a specific folder using cmd

Replace John with your Windows account folder name. The /d option lets cd change both the drive and directory when necessary.

If you know the complete file path, you can skip cd and use the start command directly.

3 Open a File with a Specific Program

To open a file in an application other than its default, enter the program's command followed by the file path.

For example, open a text file with Notepad:

notepad "C:\Files\notes.txt"

open a file with a specific program using cmd

You can also launch an application using its executable path:

"C:\Program Files\AppName\app.exe" "C:\Files\report.txt"

Replace the example executable and document paths with the actual locations. The application must support the file format and accept the file path as an argument.

4 Open a File or Folder in File Explorer

Use explorer when you want to access a location in File Explorer rather than open a file directly in its associated application.

To open a folder:

explorer "C:\Files"

open a file in file explorer with cmd

To open the folder and select a specific file:

explorer /select,"C:\Files\report.pdf"

The first command opens the folder. The second opens its containing folder and highlights the specified file.

How to Open Different File Types Using CMD

You can open many common file types with CMD using the same start command. The application Windows launches depends on the file association and the software installed on your computer.

File Type CMD Command Example What It Does
TXTstart "" "C:\Files\notes.txt"Opens the text file in its default application.
PDFstart "" "C:\Files\report.pdf"Opens the PDF in its default viewer or browser.
JPG / PNGstart "" "C:\Files\photo.jpg"Opens the image in its default viewer.
DOCX / XLSXstart "" "C:\Files\report.docx"Opens the document or spreadsheet in its associated application.
MP4start "" "C:\Files\video.mp4"Opens the video in its default media player.
EXE"C:\Files\app.exe"Runs the executable program.

Replace the example paths and filenames with the actual ones on your computer.

Unlike the other examples, an EXE file runs a program directly rather than opening a document in its associated application.

How to Find a File Using CMD

When you don't know a file's exact location, use the dir command to list files or search within a folder.

List Files in a Folder with dir

To display files and subfolders in the current directory, enter:

dir

find a file using cmd with dir

To view the contents of a specific folder, use:

dir "C:\Files"

Review the output for the filename and extension. Once you find the file, use its path with the start command.

Search for Files in Subfolders

The /s option makes dir search the specified directory and its subfolders.

To search for a file named report.pdf under C:\Files, run:

dir /s /b "C:\Files\report.pdf"

CMD displays the matching file path if it finds one. You can then use that path to open the file.

Search within a specific directory when possible. Searching a large drive may take longer and return many results.

Search by File Name or Extension

Wildcards help you find files when you know only part of a filename or its extension.

To find PDF files under a folder and its subfolders, run:

dir /s /b "C:\Files\*.pdf"

To find files whose names begin with report, use:

dir /s /b "C:\Files\report*"

The asterisk (*) matches any number of characters. These commands search filenames and paths, not file contents. Keep in mind that a file's extension helps identify its format. If you cannot find one, try changing file extensions.

Also note that these commands only find files that remain accessible in the specified location, not files that have already been deleted.

How to Fix a File That Won't Open Through CMD

A file may not open in CMD because of a path, application, or file issue.

CMD Cannot Find the File or Path

Check the filename and path for typing errors. Use dir to confirm that the file exists in the specified folder:

dir "C:\Files\report.pdf"

If the path contains spaces, enclose it in double quotes. When using start, include the empty title parameter:

start "" "C:\Program Files\report.pdf"

If CMD still cannot find the file, check whether it has been moved or deleted.

The File Opens in the Wrong Application

Specify a compatible application to open the file. For example, use this command to open a text file in Notepad:

notepad "C:\Files\notes.txt"

You can also change the default application through Windows Settings.

The File Exists but Won't Open

If the path is correct but the file still won't open, check whether the application supports its format, the file is damaged, or access is restricted. Try a compatible application or another copy of the file. If the file is missing from its original location, check your backups or consider data recovery.

How to Recover Deleted or Lost Files Using 4DDiG

If CMD can't find a file, it may have been deleted or lost from its original location. In this case, CMD commands can't recover it, but 4DDiG Data Recovery can scan supported storage devices for lost files, including documents, photos, and videos.

It supports recovery from internal and external hard drives, SSDs, USB flash drives, memory cards, Recycle Bin, and other supported storage media. You can preview available results and select the files you want to recover.

FREE DOWNLOAD

Secure Download

FREE DOWNLOAD

Secure Download

  • Download and install 4DDiG on your computer, then launch it. Select the drive or partition where the missing file was originally stored. 4DDiG will automatically start scanning for lost files.

    select the drive in 4DDiG
  • Use the Filter or Search feature to locate the missing file by name or file type. You can also pause or stop the scan at any time.

    search for missing files in 4ddig
  • Double-click a scan result to preview the file and check whether it contains the content you need. Select the recoverable files and click "Recover".

    preview missing files before recovery
  • Choose a different drive or location to save the recovered files, then click "Save Now".

    save recovered files to a different location
notes icon Notes

Save recovered files to a different drive or location rather than the original one. This helps reduce the risk of overwriting data that may still be recoverable.

Conclusion

Knowing how to open a file from cmd helps you launch applications and access files directly from Command Prompt. When a file can't be found, check its path first. If it has been deleted or lost, 4DDiG offers another way to try to get it back.

William Bollson (senior editor)

William Bollson, the editor-in-chief of 4DDiG, devotes to providing the best solutions for Windows and Mac related issues, including data recovery, repair, error fixes.

(Click to rate this post)

You rated 4.5 ( participated)