1. Home
  2. Windows Tips
  3. Open files and folders from the command prompt windows 10

How to open files and folders from the Command Prompt on Windows 10

The Command Prompt can do a lot things the Windows 10 UI doesn’t give you simple, quick access to. It can also do some basic stuff like open files and folders. The commands you need for it are pretty simple. Here’s how you can open files and folders from the Command Prompt.

Open files from Command Prompt

The only real trick to opening a file from the Command Prompt is moving to the correct folder that the file is in. You can do that, or you can give the full path to the file you want to open.

Move to folder

If you’re going to move to the folder that the file is in, you need to use the cd command.

Syntax

cd path-to-folder

Example

cd C:\Users\fatiw\Desktop

Once you’re in the correct folder, enter the name of the file you want to open with its extension and tap enter.

Open file directly

To open the file directly, instead of moving to the folder, you need to specify the path with the name of the file you want to open, with the file extension.

Syntax

path-to-folder FileName.FileExtension

Example

"C:\Users\fatiw\Desktop\audio cut.jpg"

By default, Command Prompt will open the file in the default app that is set for it however, if you want, you can specify a different app to open the file.

Syntax

Path-to-app app-EXE-name path-to-file FileName.FileExtension

Example

"C:\Program Files\Adobe\Adobe Photoshop CC 2018\Photoshop.exe" "C:\Users\fatiw\Desktop\audio cut.jpg"

Open folder from Command Prompt

To open a folder in File Explorer from Command Prompt, you need to run the following command.

Syntax

start %windir%\explorer.exe path-to-folder

Example

start %windir%\explorer.exe "C:\Users\fatiw\Desktop"

Since we’re just opening files and folders, you don’t need to open Command Prompt with admin rights. The commands will work regardless what privileges Command Prompt is running with.

One thing you ought to know about providing the path to a file or folder is that you need to enclose it in double-quotes. This is normal since most folder and file names have a space in them. If you neglect to use the double-quotes, the command won’t run. If your file name and folder path don’t have any spaces in them, feel free to run the commands without the double-quotes.

Close File

You can also use Command Prompt to close a file. The command is;

Syntax

taskkill /im filename.exe /t

Example

taskkill /im i_view64.exe /t

Of course, if an app is able to run multiple instances, like IrfanView or Microsoft Word, the command will close all the files that are open. You might lose unsaved progress so be careful with this one.

1 Comment