How To Open a File from the Command Prompt

Posted by Arch on June 4, 2019
How to Open a File in Command Prompt

There are a lot of things you can do in Command Prompt on Windows 10. Still, this is one of the most underutilized apps some users never even open. The Command Prompt interface might look a bit intimidating due to command lines, specific syntax/code, and lack of clickable graphics interface.

However, there is nothing to be afraid of, entering the wrong code/command is not going to mess up your PC, the command just won’t execute. You should know that certain actions are much faster via Command Prompt – file access, for example.

This article will explain you all the necessary commands to open a file, close it, open a folder, and move to a folder. Plus, there is a special section for running programs via Command Prompt.

Opening a File

Note: All of the following explanations assume you already opened Command Prompt. Type Cmd in Windows search and click on the app in results to run it. If you use Windows 8, select the magnifying glass icon from the pop-up window.

To access a file directly, Command Prompt requires you to enter the specific path. This means you need to enter the file name and its respective extension. This is the syntax of the command: path-to-folder FileName.FileExtension.

For example, your command should look like this: “C:\Users\Lela\Desktop\audiocut.jpg”. The file opens in the default app, but you can also assign a different app to open it. Here is the command syntax: Path-to-app app-EXE-name path-to-file FileName.FileExtension.

open file in command prompt

Here is what the exact command looks like: “C:\Program Files\Adobe\Adobe Photoshop CC 2018\Photoshop.exe” “C:\Users\Lela\Desktop\audiocut.jpg”. Of course, this is just an example and the path differs based on the file destination/extension and the app you want to run it with.

Closing a File

The command to close a file is even simpler and it follows the taskkill /im filename.exe /t syntax. The example command can be: taskkill/im i_view64.exe /t.

open file in cmd

This command closes all the files that are open, even if they run in different apps like Microsoft Word or IrfanView. So you need to use it carefully, to avoid losing your progress or data.

How to Open a Folder

This command to open a folder follows this syntax: start %windir%\explorer.exe path-to-folder. Here is an example of the exact path: start %windir%\explorer.exeC:\Users\Lela\Desktop“.

how to open file in cmd

It’s important to note that the commands to open files and folders work without administrator rights. You should enclose the file or folder path in double quotes because they have specific names with spaces in between. On the other hand, if there are no spaces in the names the commands run without the double quotes.

Note: For grammar purposes, some example codes in this article have a full stop at the end of the sentence. When you use the command, omit the full stop.

Moving to Folder

The “cd” command is used to navigate to the folder that contains the file you are looking for. The syntax is simple and it looks like this: cd path-to-folder. The example may be: cd C:\Users\Lela\Desktop.

When you get inside the folder, type the name of the file you are looking for together with the respective extension and hit Enter.

Running Basic Programs

As indicated, you can run any program with simple commands and for this to work you might need administrative privileges. The syntax for running basic programs is: start program_name. Here is the list of commands you might find useful:

  1. start calc (Calculator)
  2. start notepad
  3. start explorer (File Explorer)
  4. start cmd (new Command Prompt window)
  5. start wmplayer (Windows Media Player)
  6. start mspaint (Paint)
  7. start taskmgr (Task Manager)
  8. start charmap (Character Map)

Hit Enter when you type the command and the given program should appear in a moment. You should make sure there is a space between the “start” part and the program name, but even so, some apps may not run. This usually means their folder is not in the search path of Command Prompt.

Command Prompt Tricks

If you use the command 1 && command 2 syntax, it allows you to execute two different commands one after the other. For example, mspaint && ipconfig opens paint, then configuration.

To see what drivers are running on your PC, type driverquery and hit Enter. And what’s best about the commands, you can send them to the clipboard by typing ipconfig | clip. This way you will spend less time copying and pasting the commands you might frequently use.


When all is said and done, opening a file via Command Prompt is much quicker than navigating through all the folders on your computer. You do need to know the exact file path/location, but you can easily find it with File Explorer on your computer.

Leave a Reply

Your email address will not be published. Required fields are marked *

Disclaimer: Some pages on this site may include an affiliate link. This does not effect our editorial in any way.