Many of the tasks you can perform via your UI, you can also do in Command Prompt. This extends to opening files and folders, which you may want to do if you’re using a GUI-less install, or your File Explorer is broken. Today we’re going to show you how to open a file or folder in Command Prompt in Windows 11 in just a few seconds.
To do so, we’ll be making use of the new Windows Terminal application, which allows you to quickly access CMD, PowerShell, and more.
How to change directory in command prompt
As part of the process, this tutorial will briefly cover how to navigate to files in CMD. It won’t, however, show you how to open Command Prompt in a specific folder, as we already have a tutorial on that here. With that said, lets’ get started:
How to Open a File in Command Prompt
To open a file using Command Prompt, you just need to navigate to its folder and then type the file name. Here’s an example:
- Right-click your Start button and press “Windows Terminal (Admin)”
- Click the dropdown arrow next to the plus icon and select “Command Prompt”
- Navigate to your desired folder with “cd”, then type your file name in quotes
For example, our file is in the “wonder” folder on our desktop. To get there, you would type:
cd C:\Users\User Name\Desktop\wonder
We know that the file is called “cafe” and is a jpeg filetype, so to open it we can just type
"cafe.jpg"and press Enter.
If you’re unsure what your file is called, you can type
lswhile in a folder. This will list every file inside of it in CMD.
- Your file will open in its default program
- Try opening a different file type
This trick works not just with images, but documents and basically any file on your PC that you have the software to open. In the example below, we navigate to a folder on the desktop and then open an excel worksheet:
cd C:\Users\Maria Winbuzzer\Desktop\wonder
- Your Excel workbook will open in its default program: Excel
How to Open a Folder in CMD
Opening a folder in Command Prompt is even easier. You can do it in a single command. It’s not the easiest to remember, but every convenient once you have it down. Note that this is different from navigating to a folder in CMD because it will actually open the file in Windows Explorer:
- Type the following command and Press Enter
With Command Prompt selected in your terminal type the following command and substitute the folder path with one to the folder you want to open:
start %windir%\explorer.exe "C:\Users\Maria Winbuzzer\Desktop\wonder"
- Windows will open your folder in File Explorer
Extra: How to Stop, Start, and Restart a Service with Command Prompt
As we mentioned, there are hundreds of things you can do with Command Prompt rather than using the UI. One of them is managing your services. You can learn how by following our dedicated guide here.
Extra: How to Run Windows Defender from the Command Line
You can also run Windows Defender from Command Prompt, updating it, performing scans, and more. Follow our existing tutorial to find out how.