How can I open a cmd window in a specific location without having to navigate all the way to the directory I want?
How can I open a cmd window in a specific location without having to navigate all the way to the directory I want?
This might be what you want:
cmd /K "cd C:\Windows\"
Note that in order to change drive letters, you need to use cd /d. For example:
C:\Windows\System32\cmd.exe /K "cd /d H:\Python\"
If you have Windows Vista or later, right-click on the folder icon in Explorer while holding the Shift key, and then click on the "Open command window here" or "Open PowerShell window here" context menu option.
If you're already in the folder you want, you can do one of the following:
For Windows XP, use the PowerToy mentioned by dF to get the same function.
Try out this "PowerToy" from Microsoft:
Open Command Window Here
This PowerToy adds an "Open Command Window Here" context menu option on file system folders, giving you a quick way to open a command window (cmd.exe) pointing at the selected folder.
EDIT : This software will not work on any version of Windows apart from Windows XP.
On Windows Vista, Windows 7 and Windows 10 simply hold down the Shift key and right-click on a folder.
The context menu will contain an entry titled: "Open command window here"
Update: Type "cmd" in the address bar of Explorer and press enter
Update 2: In windows 10, go to file menu and select "Open Windows PowerShell". There is an option for running as administrator.
Use the /K switch. For example
cmd /K "cd /d c:\WINDOWS\"
Will create a cmd window at the C:\Windows directory
In windows go to folder location in file explorer remove path and type cmd and press enter. and path will open in cmd.
If you are starting cmd from taskbar, this is what you need to do:
right click --> rightclick on Command Prompt --> Properties
Then in the properties window change the value of Start in:
This solution doesn't work for opening command prompt as administrator
Create a shortcut and edit the "Start In" property of the shortcut to the directory you want the cmd.exe to start in.
Update: This is built into Windows now. See this answer.
The XP powertoy is a good option, but I thought I'd post another, in case you'd like to "roll your own". Create a text file, name it anything.reg, paste in the code below, save it, then double-click on it to add it to the registry (or just add the info to the registry manually if you understand what's going on in this .reg file).
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\shell\Command_Prompt_Here...]
@="Command Prompt Here..."
[HKEY_CLASSES_ROOT\Folder\shell\Command_Prompt_Here...\command]
@="cmd.exe \"%1\""
Update: After an Windows-update, Win10 removed the cmd-here feature. To reactivate it you've to use:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\cmd]
@="@shell32.dll,-8506"
"Extended"=""
"NoWorkingDirectory"=""
"ShowBasedOnVelocityId"=dword:00639bc8
[HKEY_CLASSES_ROOT\Directory\shell\cmd\command]
@="cmd.exe /s /k pushd \"%V\""
The entry ShowBasedOnVelocityId is mandatory
This answer is for windows 10.
Create a command prompt shortcut in the folder wherever you want, then right click on that shortcut

and
In Windows go to the specific folder, then click on the file explorer path and remove it then type cmd and click enter.. and in cmd your specific folder with its path will open..
<===||==========> On Windows 10 <==========||===>
Assuming that in File Explorer you have opened the target directory/folder, do this :
Click on address bar, alternatively press Alt + A
Now when address bar is highlighted, type cmd in the bar.
Press Enter key
For a powershell window :
Alt + f + s + aRight click the desktop and navigate to new and then from the sub-menu select "shortcut" → Browse to the Windows directory (or folder) and then to the system32 directory and click OK.
Add a \ and "cmd.exe" (without the quotes) to the command string. It should look like this:
C:\WINDOWS\System32\cmd.exe.
Click Next and Finish. Right click the new CMD icon on your desktop and select properties, and Next to the Start. In options, delete the line and add the path to wherever the directory is that you want it to start in... For example, C:\temp\mp3 and click OK.
In my case I VERY SPECIFICALLY wanted an opened CMD window in ADMIN mode in a specific folder. Here's how (works for Windows 7):
In the target folder, create START.BAT that simply contains one line:
start cd c:\MyTargetFolder
Drag a shortcut from START.BAT and call it "START AS ADMIN".
Right-click the shortcut and select "Run as Administrator" and "Run Minimized". Also make sure that the "Start In" will cause the same drive to be selected (as CD does not change the drive!).
When you click on that shortcut you will get the UAC prompt and then an open command window in the desired folder. The title bar will show that this CMD window is in ADMINISTRATOR mode.
Rather than saving it as a shortcut, this is how I do it and I find it very useful. There are already answers to show as a shortcut, but I just wanted to share this, especially I find it very useful for angular projects.
@ECHO OFF
cd C:\YourProjectPath\FolderPath\save as .bat file with a convenient name. (I usually save it as "goto-myProjectName.bat"
Then copy that bat file into your default path (when you run the cmd, whatever is your default path, it starts with that. For instance, on my machine it is windows/system32)
goto-myProjectNameThen it should take you to there.
Another easy solution is to install Windows Terminal.
And then you automatically have "Open in Windows Terminal" when you right-click on a folder:
You can also do this:
[HKEY_CLASSES_ROOT\Directory\shell\cmd]
@="command prompt here"
[HKEY_CLASSES_ROOT\Directory\shell\cmd\command]
@="cmd.exe /c start \"%1\" cmd.exe /k cd /d %1"
[HKEY_CLASSES_ROOT\Drive\shell\cmd]
@="command prompt here"
[HKEY_CLASSES_ROOT\Drive\shell\cmd\command]
@="cmd.exe /c start \"%1\" cmd.exe /k cd /d %1"
Update: for Win10 you need ShowBasedOnVelocityId - see answer above.
Despite a few answers for HKCR\Directory\shell under Windows 10 (which did not work) the following worked for me:
SetOpenCmdHere.reg
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\shell\cmd]
@="Open CMD here..."
[HKEY_CLASSES_ROOT\Folder\shell\cmd\command]
@="C:\\Windows\\system32\\cmd.exe /k pushd \"%1\""
Windows 10 File Explorer now has a "Quick Access Toolbar".
Just press "Alt+F" to open the file menu, navigate to the "Open Windows PowerShell" menu, right click and select "Add to Quick Access Toolbar":
Now you will get a little icon that you can click on, that will open PowerShell in the directory you are in:

Why that much of setup, for this simple matter, when your on the path in cmd just enter
start .
and press Enter