Windows open file cmd windows

On Mac OS X and GNOME on Linux, there are commands that can be used to open files from the command line in their associated GUI editors: open and gnome-open, respectively. Is there any command like this for Windows?

asked Feb 17, 2011 at 2:30

Wuffers's user avatar

4

If you are currently in the command prompt and have a file called test.png and , which are located in c:\test you can do the following:

If you are at the directory (so should say c:\test>) just type:

test.png

which would open test in the default png picture editor.

If the files name contains spaces, then simply enclose the file name within » «

 "this image.png"

You can alternatively type:

c:\test\test.png

which will open the file no matter where you currently are.

Finally, you can pass the picture to another program. For example, if you have an image editor called imageedit.exe and it supports opening files through command lines (and if the program is pathed/accessible or you are in it’s current directory), you can type the following:

 imageedit c:\test\test.png

Community's user avatar

answered Feb 17, 2011 at 2:38

William Hilsum's user avatar

William HilsumWilliam Hilsum

117k19 gold badges182 silver badges266 bronze badges

4

If it is a registered extension, you can use «start» as in

start WordDoc.doc

Tamara Wijsman's user avatar

answered Feb 17, 2011 at 2:36

Dennis's user avatar

DennisDennis

6,5881 gold badge28 silver badges28 bronze badges

5

On Windows command-line explorer "<PATH>" will open the file path with Windows default associated programs. This will also handle all URIs ( http:,https:,ftp: ) and other file protocols defined in Windows Operating System.
If the file or protocol is not associated with any program then an Open With dialog will show up. If file is not present then default My Documents folder will open up. It can also open executable files ( EXE, BAT files) and shell namespace paths.

Examples

explorer "http://www.google.com"— will open http://www.google.com in windows default browser.

explorer "file:///C:\temp\" will open temp directory if present

explorer "file.txt" will open file.txt on the current directory path .i.e. %CD% path

explorer ::{645ff040-5081-101b-9f08-00aa002f954e} will open RecycleBin.

You can refer about explorer’s other useful command-line switches here

oldherl's user avatar

oldherl

2031 silver badge8 bronze badges

answered Jul 7, 2017 at 18:17

lalthomas's user avatar

lalthomaslalthomas

3172 silver badges9 bronze badges

The first parameter of Start is a window title, so if you have a space in the file name, and you type

Start «My File.txt»

you’ll get a command line window with «My File.txt» as the title. To get around this use a dummy title,

Start «my title» «My File.txt»

Depending on the file and what application is opened there probably won’t be a window to see anyway.

answered Jan 27, 2017 at 14:27

Steven Digby's user avatar

1

If you are in PowerShell
(at the PS (current-directory)>  prompt),
and you want to open a file in the current directory,
you may try this .\myfile.ext
If you are in the Command Prompt, you can accomplish the same result by typing

powershell -c .\myfile.ext

(You must include the .\,
as PowerShell doesn’t load files from the current location by default.) 
Or you can provide a directory name (relative or absolute)
if the file isn’t in the current directory.

For the first scenario — if you are in PowerShell —
if the filename contains space(s),
enclose it in quotes (either kind) and precede it with
the & symbol:

PS C:\Users\myusername\Pictures> &".\funny cat.jpg"

(You may add a space after the & for readability,
if you prefer readability, and you may use / instead of \.) 
I don’t know how to make this work in the second scenario
(in which you are running powershell -c from Command Prompt)
if the file or directory name contains space(s) — quotes don’t seem to help.

Scott - Слава Україні's user avatar

answered Oct 19, 2018 at 14:25

andrey.shedko's user avatar

0

This may come a bit late, but the correct command for editing a file name in Windows 7 is «write file_name»

This should open up the default text editor and you should be able to edit the file easily

Edit: It seems to open only Wordpad. For me that was the default text editor.

answered Jul 31, 2014 at 18:11

Coder's user avatar

CoderCoder

12 bronze badges

3

Specific executable with specific file:

Git Bash Script On Windows 10 :


SHORTCUTS_MAIN_START.sh :

    FILE_PATH="C:\DEV\REPO\GIT\AHK03\SHORTCUTS\SHORTCUTS_MAIN.ahk"
    EXEC_PATH="C:\DEV\REPO\GIT\AHK03\AHK_ROOT\AutoHotkeyU64.exe"

    $EXEC_PATH $FILE_PATH

This example opens the file denoted by $FILE_PATH with the executable denoted by $EXEC_PATH. If this doesn’t work for you, try converting the single slash ( «\» ) into double slashes ( «\\» ) for the paths.

Community's user avatar

answered Sep 19, 2017 at 16:16

KANJICODER's user avatar

KANJICODERKANJICODER

3573 silver badges6 bronze badges

In the Windows command prompt, you can run

edit [file_name]

in order to view batch files/logs/text files etc. This command requires QBASIC.EXE, which is by default present in Windows.

See here for other useful MS-DOS commands.

Dave's user avatar

Dave

25.3k10 gold badges58 silver badges70 bronze badges

answered Sep 10, 2012 at 6:54

Ph03nIX's user avatar

3

You must log in to answer this question.

Not the answer you’re looking for? Browse other questions tagged

.

On Mac OS X and GNOME on Linux, there are commands that can be used to open files from the command line in their associated GUI editors: open and gnome-open, respectively. Is there any command like this for Windows?

asked Feb 17, 2011 at 2:30

Wuffers's user avatar

4

If you are currently in the command prompt and have a file called test.png and , which are located in c:\test you can do the following:

If you are at the directory (so should say c:\test>) just type:

test.png

which would open test in the default png picture editor.

If the files name contains spaces, then simply enclose the file name within » «

 "this image.png"

You can alternatively type:

c:\test\test.png

which will open the file no matter where you currently are.

Finally, you can pass the picture to another program. For example, if you have an image editor called imageedit.exe and it supports opening files through command lines (and if the program is pathed/accessible or you are in it’s current directory), you can type the following:

 imageedit c:\test\test.png

Community's user avatar

answered Feb 17, 2011 at 2:38

William Hilsum's user avatar

William HilsumWilliam Hilsum

117k19 gold badges182 silver badges266 bronze badges

4

If it is a registered extension, you can use «start» as in

start WordDoc.doc

Tamara Wijsman's user avatar

answered Feb 17, 2011 at 2:36

Dennis's user avatar

DennisDennis

6,5881 gold badge28 silver badges28 bronze badges

5

On Windows command-line explorer "<PATH>" will open the file path with Windows default associated programs. This will also handle all URIs ( http:,https:,ftp: ) and other file protocols defined in Windows Operating System.
If the file or protocol is not associated with any program then an Open With dialog will show up. If file is not present then default My Documents folder will open up. It can also open executable files ( EXE, BAT files) and shell namespace paths.

Examples

explorer "http://www.google.com"— will open http://www.google.com in windows default browser.

explorer "file:///C:\temp\" will open temp directory if present

explorer "file.txt" will open file.txt on the current directory path .i.e. %CD% path

explorer ::{645ff040-5081-101b-9f08-00aa002f954e} will open RecycleBin.

You can refer about explorer’s other useful command-line switches here

oldherl's user avatar

oldherl

2031 silver badge8 bronze badges

answered Jul 7, 2017 at 18:17

lalthomas's user avatar

lalthomaslalthomas

3172 silver badges9 bronze badges

The first parameter of Start is a window title, so if you have a space in the file name, and you type

Start «My File.txt»

you’ll get a command line window with «My File.txt» as the title. To get around this use a dummy title,

Start «my title» «My File.txt»

Depending on the file and what application is opened there probably won’t be a window to see anyway.

answered Jan 27, 2017 at 14:27

Steven Digby's user avatar

1

If you are in PowerShell
(at the PS (current-directory)>  prompt),
and you want to open a file in the current directory,
you may try this .\myfile.ext
If you are in the Command Prompt, you can accomplish the same result by typing

powershell -c .\myfile.ext

(You must include the .\,
as PowerShell doesn’t load files from the current location by default.) 
Or you can provide a directory name (relative or absolute)
if the file isn’t in the current directory.

For the first scenario — if you are in PowerShell —
if the filename contains space(s),
enclose it in quotes (either kind) and precede it with
the & symbol:

PS C:\Users\myusername\Pictures> &".\funny cat.jpg"

(You may add a space after the & for readability,
if you prefer readability, and you may use / instead of \.) 
I don’t know how to make this work in the second scenario
(in which you are running powershell -c from Command Prompt)
if the file or directory name contains space(s) — quotes don’t seem to help.

Scott - Слава Україні's user avatar

answered Oct 19, 2018 at 14:25

andrey.shedko's user avatar

0

This may come a bit late, but the correct command for editing a file name in Windows 7 is «write file_name»

This should open up the default text editor and you should be able to edit the file easily

Edit: It seems to open only Wordpad. For me that was the default text editor.

answered Jul 31, 2014 at 18:11

Coder's user avatar

CoderCoder

12 bronze badges

3

Specific executable with specific file:

Git Bash Script On Windows 10 :


SHORTCUTS_MAIN_START.sh :

    FILE_PATH="C:\DEV\REPO\GIT\AHK03\SHORTCUTS\SHORTCUTS_MAIN.ahk"
    EXEC_PATH="C:\DEV\REPO\GIT\AHK03\AHK_ROOT\AutoHotkeyU64.exe"

    $EXEC_PATH $FILE_PATH

This example opens the file denoted by $FILE_PATH with the executable denoted by $EXEC_PATH. If this doesn’t work for you, try converting the single slash ( «\» ) into double slashes ( «\\» ) for the paths.

Community's user avatar

answered Sep 19, 2017 at 16:16

KANJICODER's user avatar

KANJICODERKANJICODER

3573 silver badges6 bronze badges

In the Windows command prompt, you can run

edit [file_name]

in order to view batch files/logs/text files etc. This command requires QBASIC.EXE, which is by default present in Windows.

See here for other useful MS-DOS commands.

Dave's user avatar

Dave

25.3k10 gold badges58 silver badges70 bronze badges

answered Sep 10, 2012 at 6:54

Ph03nIX's user avatar

3

You must log in to answer this question.

Not the answer you’re looking for? Browse other questions tagged

.

  • Home
  • News
  • How to Open a File/Folder in Command Prompt (CMD) Windows 10

By Alisa |
Last Updated

Wonder how to open a file cmd or how to open a folder in Command Prompt on Windows 10? This tutorial provides a step-by-step guide. Also, if you can’t find some files or folders in Windows 10, or some files are unexpectedly lost in your Windows 10 computer, MiniTool free data recovery software for Windows 10/8/7 can help you easily recover lost files.

You can also open files from Command Prompt. Wonder how to open a file or folder in Command Prompt on Windows 10? Check the step-by-step guide in this tutorial.

How to Open a File CMD Windows 10 in 2 Steps

Step 1 – Open Command Prompt

You have several ways to open Command Prompt in Windows 10.

You can press Windows + R keys on the keyboard to open Windows Run dialog. Then type cmd in the Run box. If you want to run Command Prompt as Administrator, you need to press Ctrl + Shift + Enter keys at the same time.

Alternatively, you can also click Start or Search box in Windows 10, and type cmd or command prompt. Right-click the Command Prompt app in the list and choose Run as administrator.

Step 2 – Open Files from Command Prompt

Normally you have two ways to open a file using cmd. One is to move the folder that the file is in, the other is to open the files directly in Command Prompt.

Method 1. How to open a file with cmd by moving to the folder firstly

  • You can use the cd command to move to the exact folder the file lies in. For instance, cd C:\Users\mini\Desktop.
  • After you are in the correct folder path, you can type the name of the file with its extension, e.g. “travel.png”, and hit Enter button to open it.

how to open a file cmd

Method 2. How to open a file using cmd directly

You can also choose to open files from Command Prompt on Windows 10 directly, instead of going to the folder path. You can input the full path, file name and its file extension to open the target file, e.g. “C:\Users\mini\Desktop\travel.png”.

open files from Command Prompt

You can also freely specify an app to open the file. You need to type the whole path of the app ahead of the path of the file, for example, “%windir%\system32\mspaint.exe” “C:\Users\mini\Desktop\travel.png”. Press Enter to open the file using CMD.

specify an app to open a file in Command Prompt

How to Open a Folder in Command Prompt Windows 10

You can also open a folder from Command Prompt with the command line below.

After you enter into Command Prompt window by following the operation above, you can open a folder in File Explorer in Command Prompt. The command line can be like this, start %windir%\explorer.exe “C:\Users\mini\Desktop”.

how to open a folder in Command Prompt

Tip: Need to mention that you need to enclose the path of a file or folder in double quotation marks, since some folder or files names have spaces in them.

>> Quick Video Guide:

To Recover Unexpectedly Lost Files or Folders in Windows 10

Sometimes you may suffer unexpected data loss in Windows 10 due to various reasons, e.g. system crash, Blue Screen error (e.g. Bad Pool Caller BSOD error), power outage, malware/virus infection, hard drive failure, etc. To easily recover lost data for free, you can choose the best free data recovery software to realize it.

MiniTool Power Data Recovery, a 100% clean and free data recovery software for Windows 10/8/7, enables you to easily recover mistakenly deleted files or lost files from computer local drive, external hard drive, SSD drive, USB drive (pen drive data recovery), SD card, and more.

MiniTool Power Data Recovery TrialClick to Download100%Clean & Safe

About The Author

Position: Columnist

Alisa is a professional English editor with 4-year experience. She loves writing and focuses on sharing detailed solutions and thoughts for computer problems, data recovery & backup, digital gadgets, tech news, etc. Through her articles, users can always easily get related problems solved and find what they want. In spare time, she likes basketball, badminton, tennis, cycling, running, and singing. She is very funny and energetic in life, and always brings friends lots of laughs.

The Windows Command Prompt can be used to search for and open any files on your PC. This is very useful if you saved your file to an unknown folder and only remember a part of the file name. However, there’s no benefit nor harm in applying this method to files with a known location. But for those files that are difficult to locate, this article shows how to find and open files in Command Prompt in Windows 11 and Windows 10.

Content

  • What Is the Benefit of Using the Command Prompt to Open Files?
  • How to Open Command Prompt in Windows
  • How to Search for Files Using Command Prompt in Windows
  • How to Change Directories in Windows Command Prompt for Easy Access to Folder Paths
  • How to Open Files in Command Prompt by File Name and File Type
  • How to Search for the Correct Files With Command Prompt
  • How to Open Files in Windows Command Prompt
  • How to Open Files Using Windows Terminal
  • Frequently Asked Questions

Also read: How to Use Windows Defender from the Command Prompt

What Is the Benefit of Using the Command Prompt to Open Files?

Whether you are looking for all your files concerning one topic or just trying to find the one hiding among all the folders on your computer, try using the Command Prompt. It may make it more efficient for you.

On top of that, using the Command Prompt is much faster and more responsive than opening the files from the File Explorer. This is true for video files, Windows Photos, Word documents, and heavy-duty games, as the GUI always consumes more memory and slows down the processes.

Also read: 8 Ways to Customize Windows Terminal

To search for the files in Windows, you first need to launch Command Prompt. There are several ways to do this:

  • Through Search Box. Type cmd in the Windows search box, then click on the icon to open the window. It’s wise to always operate the command line as an administrator.
Windows Command Prompt File Open Run As Administrator Search Menu
  • Use the Run window. A fast way to launch cmd is to press the Win + R keys, Then type cmd or cmd.exe and press Enter or click «OK.» To directly launch Command Prompt in Admin mode, press Ctrl + Shift + Enter.
Windows Command Prompt File Cmd Open From Run Menu
  • Use Win + X : Another fast way to launch cmd is to use the Win + X combination, also known as the Power User menu. Among the various options in Windows 11, you will find Windows Terminal and Windows Terminal (Admin), which are the latest terminal emulators to run both Command Prompt and PowerShell from one window.
Windows Command Prompt File Open Win X Open Windows Terminal Admin

Note: in certain older Windows 10 versions, when you launch the Win + X hotkey combination, you may instead see the Command Prompt and Command Prompt (Admin) options.

Windows Command Prompt File Open Command Prompt Admin Windows10
  • Use Cortana: try Cortana if it works for you. As soon as you see ther Cortana is «listening» to text, say «open command prompt,» and it will open up.
Windows Command Prompt File Open Start Command Prompt From Cortana

Also read: Windows Security Not Opening in Windows? Here are 6 Fixes

How to Search for Files Using Command Prompt in Windows

Searching for files and folders using the command line is very easy. Follow the instructions below:

  1. In Command Prompt, type dir "search term*" /s, but replace the words «search term» with the file name or a part of the name you remember. In the following screen, we are trying to search for a folder/file titled «Stock videos.»
Windows Open Files Command Prompt Search Dir Search Term
  1. Once you press Enter, it may look like nothing is happening for a second or two, but soon all the file paths mentioning the correct file or folder will be identified and named. The correct file path can be easily identified by the size of the folder.

What do all the terms mean in the command line search request?

  • dir is a command used to show files in the current directory but can also locate data elsewhere in the system.
  • The backslash (\) tells dir to search from the root directory of the current drive.
  • /s tells dir to search all sub-directories.
  • * is used by command-line apps as a wildcard. It indicates that the search will locate all file names that contain your search term.
  • Adding an asterisk at the end of the name, like business*, will find all the files with your search term at the beginning of the name.
  • If you use it at the beginning, your search will only include results with your text at the end. For example, *.jpg.
  • If you add an asterisk at each end of the search term, you will cover all the bases. No matter where your text is in the actual name of the file, that file will be listed in the results.

Also read: 15 Safe Websites for Downloading Windows Software

How to Change Directories in Windows Command Prompt for Easy Access to Folder Paths

If your target file is located in D: drive, you won’t find it anywhere in the Windows folder from the C: drive. Therefore, you should change the Windows drive path in the command line as shown below.

  1. Type cd.. which enables you to easily move one folder up.
  2. To go to D drive, just type d:, and the Command Prompt will listen to the new drive.
Windows Open Files Command Prompt Cd Change Directory One Step At A Time
  1. Using cd without the two dots allows you to set a new folder path as the default directory for systematic file navigation.
  2. Using cls clears the entire screen and returns you to the previous folder path.
Windows Open Files Command Prompt Cls Command

Also read: How to Permanently Disable Windows Defender

How to Open Files in Command Prompt by File Name and File Type

We will explore a simple demonstration of how to open a file clearly visible to you as system administrator. To do this, you would need the location of the saved file. In this example, the file that we want to open is located in the Desktop folder.

  1. Navigate to the required folder from «This PC» and right-click to select «Properties.» This will give you that folder’s path that is unique to your computer.
Windows Command Prompt Desktop Properties
  1. Using cd change your Command Prompt’s root directory to the desired folder.
Windows Command Prompt Change Folder To Desktp
  1. Once you’re set to the right folder, open the file by typing the entire filename and .filetype. In the following example, the filename is «Marathon,» and the filetype is an .MP4 video.
  1. After typing the filename/filetype command, the correct file will be launched on your desktop window.
Windows Command Prompt File Open File Name Filetype Desired Folder

Also read: 6 Ways to Check Hard Disk Health in Windows

How to Search for the Correct Files With Command Prompt

Within the destination drive, you can search for the correct file once again using the dir "search term*" /s command discussed earlier. Do take care to use the * wildcard, both at the beginning and end of the search term for a comprehensive search – especially if that folder has hundreds of files. It’s pretty common to make mistakes in the wildcards and backslash, which returns a «no label» error. If you type correctly, you will identify the folder path and the correct file name.

Windows Open Files Command Prompt Dir Open Specific File

If the folder path is very long, you can copy-paste the entire thing. Windows 11 has built-in support for copy-pasting in the command line.

For Windows 10, check out this detailed tutorial on how to cut-copy-paste in the Command Prompt. The method is simple enough: use Ctrl + A to select the entire Command Prompt screen, then, release the mouse or trackpad click. This will make any part of the command screen selectable for a copy-paste action.

Windows Command Prompt Fileopen Copypasting Command Prompt

Also read: Do I Need Antivirus Software If I Have Windows Defender?

How to Open Files in Windows Command Prompt

Once you find the file you want to open, you can open it from the Command Prompt screen using its default program without having to locate it in your file explorer.

  1. Change the directory to the immediate folder where the file is located. This can be done using cd followed by the entire folder path to the correct file. It’s common to make mistakes, so it’s better to copy-paste the entire folder path as discussed earlier. Once the correct directory menu has been opened, you can open any files.
  2. Enter the file name inside the quotation marks ".." Press Enter and the file will open using its default application.

Note: you can open multiple files from the Command Prompt once you’ve opened the correct folder. Here we are opening a single video file in the command line window.

Windows Command Prompt Fileopen Open Directly Filepath
  1. You can use specific apps to open the file of your choice in Command Prompt. For example, video files can be opened using VLC Player. Identify the file location of the app you want to use to open the desired file.
Windows Command Prompt Fileopen App Open File Location
  1. The file location of the app is accessible in «Properties.» Copying the path is useful, as it will be pasted directly to the Windows command line.
Windows Command Prompt Fileopen App Path Defined
  1. Use "App Location Path" "File Path" to open the file with the app of your choice in Command Prompt.
Windows Command Prompt Fileopen Open File Using Specific App

Navigating your computer’s files using the Command Prompt is very similar to doing the same with file explorer.

Also read: How to Hide Updates Using PowerShell in Windows

How to Open Files Using Windows Terminal

The Windows Terminal is just a modern extension of the Command Prompt. Opening files in Windows Terminal is no different than the above methods.

  1. You need to change the default Terminal application to Command Prompt from a «+» menu if it’s set at something else, such as PowerShell or Azure Cloud Shell.
Windows Command Prompt Open Files Open Cmd In Windows Terminal
  1. The Command Prompt will become the default Terminal application for opening files.
  2. In the following Windows Terminal example, we are typing cd.. to navigate to the C:\Windows folder.
  3. we are opening the Registry Editor file in that location by simply typing regedit.
Windows Command Prompt Open Files Regedit C Windows

Also read: 9 JavaScript/Node.js One-Liners You Should Know

Frequently Asked Questions

Can I open the Command Prompt window in a Windows folder?

You can open the Command Prompt window anywhere on a Windows PC. To do so in a Windows folder, navigate to the folder first, then right-click Windows terminal. The command prompt can be accessed as part of the Windows terminal.

How do I display the contents of a text file in Command Prompt?

To display the contents of a text file in command prompt, enter the type command as shown below:

type [<drive>:][<path of file>]<Name of File>

Can I edit text files in Windows Command Prompt?

You can edit, view, create or modify any text document in Command Prompt.

  1. Use the type command followed by the file name.
  2. Copy-paste the text in the command window using copy con followed by the text name and location.
  3. Edit the document.

Can I batch rename files in Command Prompt?

Image credit: claudiodivizia by 123RF. All screenshots by Sayak Boral

Sayak Boral

Sayak Boral is a technology writer with over eleven years of experience working in different industries including semiconductors, IoT, enterprise IT, telecommunications OSS/BSS, and network security. He has been writing for MakeTechEasier on a wide range of technical topics including Windows, Android, Internet, Hardware Guides, Browsers, Software Tools, and Product Reviews.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

The command line is a powerful tool in Windows 10/11. Using the Command Prompt, PowerShell, or Windows Terminal, you can open any file you want with a single command.

One of the basic functions of the Command Prompt is creating a file, navigating folders, and opening files. Compared to using File Explorer, the command line makes it quick work to open a file by avoiding the need to navigate through various folders and menus. To open a file using Command Prompt or PowerShell, all you have to do is type the appropriate command and press Enter.

Opening files from the command line is especially useful when creating scripts, opening multiple files at once, working with large files, etc. For example, I use the trick below to open Chrome using Command Prompt.

In this article, I will explain all the necessary commands and usages to open files with Command Prompt on Windows 10/11.

Table of contents:

  1. How to open a file using Command Prompt
  2. How to find a file using Command Prompt
  3. Conclusion

How To Open a File Using Command Prompt

There are three ways you can open files from the Command Prompt window. You can navigate to the folder first and then open the files, open the file directly using the full file path, or open a file with a specific program. I will show all three methods. Each method is useful in a different situation. So, learn and use them as and when needed.

Important note: Though the guide talks about Command Prompt, you can follow the same steps in PowerShell or Windows Terminal.

Open files using Command Prompt by first navigating to the folder

If you know where the file is located, you can navigate to that folder in Command Prompt and then open it. That way, you don’t have to type the full file path whenever you want to open it. This is particularly useful if you are working on multiple files in the same directory.

  1. Open Command Prompt.
  2. Use “cd C:\path\to\folder” to navigate to the folder.
  3. Type “fileName.png” to open the file in Command Prompt.
  4. Close the Command Prompt window.

Steps with more details:

First, open the Command Prompt window. To do that, search for “Command Prompt” in the Start menu and click on the top result. If you want, you can open “Windows Terminal” and then open “Command Prompt” from the title bar.

open command prompt

After opening the Command Prompt window, type “cd C:\path\to\folder” while replacing the dummy path with the real path and press Enter. This will change the directory and take you to the folder you want.

Note: If you are trying to navigate to another drive in command line, like the D drive, you must execute the “DriveLetter:” (without quotes) command where “DriveLetter” is the actual drive letter. For example, you should run “D:” (without quotes) to navigate to the D drive. Once you are in the drive, use the CD command.

Once you are in the directory, type “fileName.png” to open the file. Of course, replace the dummy file with the actual file name and extension.

open file using Command Prompt by first navigating to the folder

As soon as you do that, the file will be opened with the default program. For instance, if you are opening an image, it will be opened in the Photos app unless you set another app as the default photo viewer.

Open files using Command Prompt directly

You open files directly using the Command Prompt. i.e., without navigating to the folder first. This method is useful when you don’t want to change the directory, when opening multiple files in different directories, etc.

  1. Open Command Prompt.
  2. Type “C:\path\to\fileName.png” to open the file in Command Prompt.
  3. Close the Command Prompt window.

Steps with more details:

Open the Command Prompt window by searching for it in the Start menu. Alternatively, press the “Windows key + X” shortcut and select “Terminal.” Next, open Command Prompt from the terminal title bar dropdown menu.

open command prompt

In the Command Prompt window, type the line below with quotes while replacing the dummy file path with the real one. Of course, don’t forget the file extension.

 "C:\path\to\fileName.png"

For example, I’d use the below command line to open an Excel file.

 "D:\WindowsLoop\My Folder\Yearly Commissions.xlsx"

As soon as you do that, the file will be opened in the default program. In my case, it will be the MS Excel application.

open a file using command prompt

Open files with a specific program using Command Prompt

Sometimes, you might want to open a file with a specific program. For example, rather than opening an image file with the default Photos app, you might want to use an alternate program like Photoshop, Quick Picture Viewer, etc. In those cases, you can use the below method.

  1. Open Command Prompt.
  2. Type “C:\path\to\program.exe” C:\path\to\fileName.png” to open the file in Command Prompt with a specific program.
  3. Close the Command Prompt window.

Steps with more details:

Open the Command Prompt window by searching for it in the Start menu. Alternatively, press the “Windows key + X” shortcut and select “Terminal.” Next, open Command Prompt from the terminal title bar dropdown menu.

open command prompt

Next, run the below command with quotes while replacing the program and file paths with real paths.

 "C:\path\to\program.exe" C:\path\to\fileName.png"

For example, I want to open an image with Quick Picture Viewer. So, I use the below command.

 "C:\Program Files (x86)\QuickPictureViewer\quick-picture-viewer.exe" "D:\WindowsLoop\My Image.png"

The file will be opened with the selected application as soon as you execute the command.

open file with a specific program using command prompt

How To Find a File Using Command Prompt

Sometimes, you might want to find the file in Command Prompt before opening it. This is especially true if you want to confirm the file exists before opening it so that you don’t face errors.

Here’s how to find files in Command Prompt:

  1. Open Command Prompt.
  2. Use “cd C:\path\to\folder” to navigate to the folder.
  3. Run the “dir “\search term*” /s” command to search and find the files.
  4. To find a specific file, run the “dir “\fileName.png” /s” command.
  5. Close the Command Prompt window.

Steps with more details:

Open the Command Prompt window by searching for it in the Start menu. Alternatively, press the “Windows key + X” shortcut and select “Terminal.” Next, open Command Prompt from the terminal title bar dropdown menu.

Use the CD command to navigate to the folder of your choice.

 cd "C:\path\to\folder"

In the Command Prompt window, run the below command while replacing “search term” with the actual file name and press the “Enter” button.

 dir "\search term*" /s

If you want to search for a specific file, use the full file name along with the extension. The command looks something like this:

 dir "\fileName.png" /s

As soon as you run the search command, the Command Prompt will scan the directories and sub-directories to find the file. Once found, it will list the full file path in the response.

Quickly Opening Files With Command Prompt — Conclusion

Opening files in Command Prompt is a powerful and effective way to handle your files and save time on regular tasks. I’ve gone over three methods to open files in Command Prompt and explore and find files using various commands. Depending on your use case, follow the method that is useful to you.

Learning how to use the command line to open files is a useful skill to have whether you are a casual user or a professional.

That is all. It is that simple to open a file using Command Prompt.

I hope this simple and easy Windows how-to guide helped you.

  • Windows no editor dead by daylight
  • Windows old что это за папка можно ли удалить в windows 11
  • Windows on the world фредерик бегбедер читать
  • Windows no editor pak что это
  • Windows on the world фредерик бегбедер книга скачать