# How to Open File With Command Prompt & PowerShell

Want to open a file from the command line? Here how you can open a file using Command Prompt or PowerShell in simple steps.

To open a file in Windows, all you have to do is double-click on it with your mouse. Alternatively, you can also select it and press the Enter key on your keyboard. As long as there is a compatible program, the file will be opened almost immediately. In a vast majority of situations, opening a file like this is good enough. However, there will be times when you might what to open a file using command line tools like Command Prompt or PowerShell.

There might be any number of situations where you need to open files using Command Prompt. For example, if you want to run a program with special flags, you generally have to run it using Command Prompt or create a desktop shortcut with the special flags. In fact, you can even create batch files and run them to open files via other programs like the task scheduler.

No matter the reason, if you ever need to open a file with Command Prompt or PowerShell, follow the steps given below. The steps listed below will work in all versions of Windows.

## Open File using Command Prompt

To open a file using Command Prompt in Windows, follow the below steps.

1. Open the Command Prompt window. On Windows, you can do that by searching for “cmd” in the Start menu or by executing the “cmd” Run command.

2. In the Command Prompt window, execute the below command to go to the folder where the file you want to open is located.

cd "path\to\folder"

3. Next, type the file name along with its extension and press Enter. For example, if you want to open a JPEG file, you have to type “image.jpeg”.

Note: If the file name has spaces, type it in quotes (Ex: “my image.jpeg”).

4. To open the file in Command Prompt with a specific program, use the below command.

"path\to\program.exe" "path\to\file"

If the program is added to the Windows path, you don’t have to type the full program path. You can just type it as following:

program.exe "path\to\file"

## Open File using PowerShell

To open a file using PowerShell, follow the steps given below.

1. Open the PowerShell window. You can do that on Windows by searching for it in the Start menu. Alternatively, right-click on the Start menu and select the “Windows PowerShell” option.

2. Use the below command to go to the folder where the file you want to open is located. This step is not necessary but if you don’t do this, you have to manually type the full file path instead of just the file name.

cd "C:\path\to\folder"

3. Once you are in the folder, execute the below command to open the file with PowerShell. Replace the dummy file name with the actual file name and its extension. As long as there is a compatible program, the file will be opened.

"./file name.jpg"

4. To open the file with a specific program, execute the below command. Don’t forget to replace the dummy paths with the actual program and file paths.

“C:\path\to\program.exe” “D:\path\to\file.png”

Important note: Some files might require admin rights to open. In that case, open the command line tool as an admin and then open the file from there.

That is all. It is that simple to open files using Command Prompt or PowerShell.

I hope that helps. If you are stuck or need some help, comment below and I will try to help as much as possible.

Scroll to Top