How do I open an Explorer window in a given directory from cmd.exe?
Categories:
Opening Explorer to a Specific Directory from the Command Line
Learn how to quickly open a Windows Explorer window to any desired directory using simple commands in cmd.exe, PowerShell, or the Run dialog.
Navigating to a specific directory in Windows Explorer can sometimes be tedious, especially if the path is long or deeply nested. Fortunately, Windows provides several command-line methods to instantly open an Explorer window at your target location. This article will guide you through the most common and efficient ways to achieve this using cmd.exe
, PowerShell, and even the Run dialog.
Using the explorer
Command
The most direct and universally applicable method is to use the built-in explorer
command. This command is designed to launch Windows Explorer and can accept a path as an argument. If no path is provided, it defaults to opening 'This PC' or 'Quick Access', depending on your Explorer settings. When a path is specified, Explorer will open directly to that location.
explorer C:\Users\YourUser\Documents\Projects
explorer .\SubFolder
explorer "D:\My Files\Important Documents"
Examples of using the explorer
command with absolute and relative paths.
Opening Explorer from the Current Directory
Often, you might already be in the desired directory within your command prompt and simply want to open Explorer to that exact location. The explorer
command offers a convenient shortcut for this: using a single dot (.
) as the path argument. This tells Explorer to open the current working directory.
cd C:\Program Files\Microsoft Office
explorer .
Navigating to a directory and then opening Explorer to that location.
flowchart TD A[Start CMD/PowerShell] --> B{Navigate to Directory?} B -- Yes --> C[Use 'cd Path\To\Directory'] B -- No --> D[Directly use 'explorer Path\To\Directory'] C --> E[Execute 'explorer .'] D --> F[Explorer Window Opens at Target] E --> F
Decision flow for opening Explorer to a specific directory.
Advanced Options and Alternatives
Beyond simply opening a directory, the explorer
command has other lesser-known but useful options. For instance, you can open Explorer and select a specific file within a directory. Additionally, PowerShell offers similar functionality, often preferred in scripting contexts.
CMD - Select File
explorer /select,"C:\Users\YourUser\Documents\report.docx"
PowerShell
Invoke-Item "C:\Users\YourUser\Pictures"
Or simply:
explorer "C:\Users\YourUser\Pictures"
Run Dialog (Win+R)
C:\Users\YourUser\Downloads
Or for current user's profile folder:
%userprofile%
/select,
argument for explorer
is particularly useful when you want to highlight a specific file within a folder, rather than just opening the folder itself.1. Open Command Prompt or PowerShell
Press Win + R
, type cmd
or powershell
, and press Enter
.
2. Navigate to the Desired Directory (Optional)
If you want to open Explorer to your current command prompt directory, use cd Path\To\Directory
.
3. Execute the explorer
Command
Type explorer .
(to open current directory) or explorer "C:\Full\Path\To\Directory"
and press Enter
. An Explorer window will immediately open at the specified location.