Thanks to the graphical user interface of Windows 10, users can get just about anything done by simply clicking on the icon. Without the GUI, we’d have been forced to do everything from the command line in PowerShell or Command Prompt.
However, learning to work with the command line is a useful skill, as it gives you quick access to functions and operations. For instance, in some situations when working on Command Prompt or PowerShell, you need to open folders or files. You don’t have to exit the window just to find the folder or file.
Open folders & files using Command Prompt & PowerShell
In this guide, I’ll show you how to open folders right from Command Prompt and PowerShell on your Windows 10 PC.
What you will learn:
- How to navigate to a folder using Command Prompt and PowerShell.
- How to open a folder using Command Prompt and PowerShell.
- How to close a file using Command Prompt and PowerShell.
In the post remember to replace
<username> with your username.
1] How to navigate to a folder using Command Prompt and PowerShell
Open the Command prompt by searching for cmd in the Start Menu and selecting Command Prompt. For PowerShell, you can also search for it and open from the Start Menu.
Type in the following command and hit ENTER to run it:
NOTE: In the above command, replace Path\To\Folder with the actual path to the folder that you want to open. So, it can become:
cd C:\Users\<username>\Desktop\New Folder
To open a file saved in this folder, input the name of the file and press ENTER. Example,
Alternatively, you can enter the full path to the file without using the cd command. For example,
2] How to open a folder using Command Prompt and PowerShell
The first technique would open a file saved in a folder. However, if you wish to open the folder in File Explorer using Command Prompt or PowerShell, you make use of the start command.
To open a folder, append the folder path after the start command. For example, I can navigate to the New Folder folder using the following command:
start C:\Users\<username>\Desktop\New Folder
If you want to open the current folder, run the start command with a fullstop (.):
To open the parent folder to your current folder, use two fullstops (..):
On hitting ENTER, the specified folder will open in a File Explorer window.
To open a folder in File Explorer using PowerShell, input either of the following cmdlets –
and add the path to the folder.
ii C:\Users\<username>\Desktop\New Folder
To open the current directory, use the following command:
3] How to close a file using Command Prompt and PowerShell
To close an already opened file using the command line, you make use of the taskkill command. First, navigate to the folder using the first method:
Enter the following command when you are in the correct directory:
taskkill /im filename.exe /t
In the above command, replace the filename part with the name of the file you want to close.
Note that this command closes every instant of the open file, and you risk losing unsaved data.
Now read: Ways to open a Command Prompt in a Folder.
I hope you find the post useful.