How To Open a File from the Command Prompt

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

How To Open a File from the Command Prompt

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 all the necessary commands to open a file, close it, open a folder, and move to a folder

Opening a File

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. Follow these steps:

  1. Type “Cmd” in Windows search and click on the app in results to run it.

  2. Navigate to the location of your file by typing the following into the command prompt window: Users\”Username”> cd C:\”Users\”Username”\”Location” In this example, the “Username” will be User and the “Location” will be desktop.

  3. Then type in the name and extension of the file you’re trying to open: “Filename.filetype.” In this example, the “Filename” will be screenshot and the “Filetype” will be .png

Closing a File

The command to close a file is even simpler and it follows this syntax: taskkill /im “filename.filetype” /t. The example Filetype in this command will be “i_view64” and the Filetype will be “.exe”

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:UsersLelaDesktop“.

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.

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.


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. Have any experience, tips or questions related to opening files using the command prompt? Leave them in the comment section below.

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.

Todays Highlights
How to See Google Search History
how to download photos from google photos