How can I open a cmd window in a specific location?
Asked Answered
F

41

444

How can I open a cmd window in a specific location without having to navigate all the way to the directory I want?

Faludi answered 13/9, 2008 at 21:51 Comment(1)
Reference: documentation provided by Microsoft on "cmd /?" Create this registry entry: Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor\ <br/>String Name: AutoRun String Value: CD [/D] {specific location} This is a command that "cmd.exe" runs every time you launch it. HTH, Marcelo FinkielszteinClaque
B
65

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.

enter image description here

Burgwell answered 13/9, 2008 at 21:53 Comment(3)
I think this answer combined with Michael Ratanapintha's answer about using shift-right click in vista and 2008 answers this question fully.Rosenarosenbaum
The link in the answer in no longer valid, but I believe it points to this download: go.microsoft.com/fwlink/?LinkId=211471Outbreak
it is valid for windows xp onlyGibbsite
G
545

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\"

(documentation)

Gunn answered 13/9, 2008 at 21:53 Comment(9)
Thanks ... Even shorter from GUI : WinLogo + R , type : cmd /c "start /max cmd /K "cd C:\Windows\""Ilana
thanks, I think this will save a lot of time (probably 3secs time of typing cd commands)Harrie
On windows 7 you can save yourself a couple of keystrokes and use a lower case k and leave out the double quotes when your pathname has no spaceImpressure
Want to start with a clean prompt without the initial cd command shown? Append &cls to the string like so: cmd.exe /K "cd /d H:\Python\&cls" (documentation) And save this line into a jumpstart.bat file for easy access by just double clicking it.Australorp
Why has this "answer" received so many up votes? Granted it answers the "letter" of the question, but not the "spirit"! This requires one to "...to navigate all the way to the directory I want." Ok, perhaps not "navigate", but rather "type", which is hardly a shortcut!Southwick
The reason this answer has received so many upvotes is that it works for a shortcut. I keep a collection of shortcuts on my taskbar that each open a command prompt window in various project folders. In Windows 8, if you create a shortcut to start an elevated command prompt window, it ignores the "Start in" folder. The workaround is to place the following in the "Target" field (not the "Start in" field) %windir%\system32\cmd.exe /k cd "\My Projects".Teetotalism
Another strategy is using AutoHotkey to start cmd.exe in various places, depending on keypress or what window has the focus. For example +#c::Run cmd.exe /K "cd /d d:\games\" will open a prompt in that folder when you hit Shift+Win+cMoynihan
I love AutoHotkey. :) Here's is a script which, when you hit Win+C, opens a command prompt in the current Windows Explorer location (provided you are showing the full path in the caption): pastebin.com/AmdvFhUi - saves doing the shift-right-click thing, for keyboard-lovers.Moynihan
you can also make a shortcut (in win 7, at least) : new shortcut and when akses for adress, just put cmd /K "cd /d c:\WINDOWS\" there. So you dont need to write it everytimeLapierre
B
354

Assuming that in File Explorer you have opened the target directory/folder, do this:

  1. Click on address bar, alternatively press Alt+D

  2. Now when address bar is highlighted, type cmd in the bar.

  3. Press Enter key

You will notice that command prompt from that folder

Belloc answered 27/4, 2014 at 7:40 Comment(8)
This is a cool trick. But do you know of a way to do this with an elevated command prompt?Kelula
@Kelula Click on the folder, click on the File menu of Explorer, then click on then arrow next to 'Open command prompt' . Then you will see an option to open cmd as AdminBelloc
@Belloc I don't get an arrow next to Open command prompt. I'm in Win7 Pro, maybe that was added in a later OS?Kelula
Yes it is with Windows10Belloc
this is nice idea and works, with just one exception: if it has sub folder named cmdHanhana
@Belloc in Win10 i only have "Open PowerShell here" option. Cmd isn't there anymore for some reason.Gist
Windows 10 doesn't include the "hold shift, right click" option so this is the only valid way I see to do this on W10.Cheremkhovo
After doing this, the address bar value changes to the path of cmd.exe. Is it possible to reset the path to the original folder? I have tried refresh the folder and type Esc in address bar, but both don't work.Appetizing
B
311

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:

  • [only Win8+] Click the Explorer Ribbon's File button, then click on "Open command window here" or "Open PowerShell window here".
  • Shift-right-click on the background of the Explorer window, then click on "Open command window here" or "Open PowerShell window here". (recommended by Kate in the comments)
  • [only Vista or Win7] Hold down Shift when opening the Explorer File menu, then click on "Open command window here". If you can't see the menu bar, open the File menu by pressing Alt-Shift-F - Alt-F to open the File menu, plus Shift.

For Windows XP, use the PowerToy mentioned by dF to get the same function.

Brost answered 13/9, 2008 at 21:58 Comment(8)
I'm running Server 2008 here and I don't get an "Open Command Window Here" context menu option when I Shift+right-click on a directory... ...doesn't work on Vista x64 either.Southwick
Works fine in Vista x64 Home Premium, and I assume other versions as well. It's about midway down the list. Note that a file cannot be selected when you right click.Eby
I particularly like the "Copy as Path" option you also get on this menu.Anastigmat
These work in Windows 7 and Server 2008 R2 also. Make sure you right click in the background and not on a file.Aryn
Works awesome in Windows 7, for me this is the best, shortest and most preferred way. Thanks @MichaelSacculus
Waaat? Holding shift enables a different context menu? Is this global behavior? Why isn't that option included in the normal context menu?Eddra
Only shows me Windows Shell in Windows 10... suggestions?Layby
In Windows 7, if you can't see the menu bar, press shift F10.Vinson
B
65

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.

enter image description here

Burgwell answered 13/9, 2008 at 21:53 Comment(3)
I think this answer combined with Michael Ratanapintha's answer about using shift-right click in vista and 2008 answers this question fully.Rosenarosenbaum
The link in the answer in no longer valid, but I believe it points to this download: go.microsoft.com/fwlink/?LinkId=211471Outbreak
it is valid for windows xp onlyGibbsite
A
59

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 #4 - 2024: The most reliable option so far has been typing "cmd" in the address bar which works in all versions of Windows including 11.

Update #1: Type "cmd" in the address bar of Explorer and press enter

enter image description here

Update #2: In windows 10, go to file menu and select "Open Windows PowerShell". There is an option for running as administrator.

enter image description here

Update #3: You can also add a quick access shortcut by going to file menu, right click on "Open windows Powershel" and select "Add to Quick Access Toolbar" and after that with one single click you can access the powershell immediately

enter image description here

Ayers answered 13/4, 2012 at 4:26 Comment(2)
I had this working on Windows 7 but in on my new laptop with Windows 10 it is not present in the popup menu.Roslynrosmarin
+1, typing "cmd" in the address bar is the only one which still lets me open a cmd on Windows 11. The options from the higher-upvoted answers all open a PowerShell.Malefaction
V
40

Use the /K switch. For example

cmd /K "cd /d c:\WINDOWS\"

Will create a cmd window at the C:\Windows directory

Vig answered 13/9, 2008 at 21:55 Comment(0)
E
40

Just write cmd in the address bar, it will open in the current folder.

Enunciation answered 10/1, 2017 at 21:17 Comment(0)
T
32

In windows go to folder location in file explorer remove path and type cmd and press enter. and path will open in cmd.

Tapioca answered 25/11, 2018 at 13:52 Comment(0)
G
26

Also, here is a shortcut to open a console in any windows folder:

  • Open any folder on windows explorer.
  • Press Alt + D to focus the adress bar
  • type cmd and press enter

Very practical shortcut.

Gt answered 1/3, 2015 at 15:44 Comment(1)
this is nice idea and works, with just one exception: if it has sub folder named cmdHanhana
F
16

pushd command sets the current folder. so:

cmd /k "pushd D:\Music"
Fibrinous answered 8/8, 2017 at 8:53 Comment(2)
Best/easiest answer I've found if you are opening a win10 administrative cmd (shortcut) prompt. Normally, admin prompt will force "start in" location to C:\Windows\system32.. no matter the 'start in' location you set.Philippa
Good tip. I use alternative 'C:\Windows\System32\cmd.exe cmd /K "cd /d D:\Bla"'.Cuirbouilli
Q
12

In Windows 8, you can click the address bar and type "cmd" (without quotes) and hit enter. This will open the cmd window in the current path.

Quantum answered 12/3, 2014 at 4:20 Comment(1)
Unless you have a batch/command script called cmd.bat or cmd.cmd, in which case it will execute that file. LOLCalycle
C
12

Easiest way is to goto the address bar of the Windows Explorer and type cmd there. It will automatically open the command prompt window for you.

Corneliuscornell answered 3/6, 2016 at 2:33 Comment(3)
The question was about how to open a prompt in a specific directory. This doesn't answer the question.Matronage
this is nice idea and works, with just one exception: if it has sub folder named cmd.Hanhana
@Matronage this actually does answer the question: navigate to the directory in Explorer, then type cmd in the directory URL at the top of the explorer window. It opens cmd right at the window's directory. No navigation in the terminal what so ever. Just to make sure everyone is on the same page: Windows Explorer is not the same thing as Internet Explorer, the Run Dialog, or the Task Manager.Despumate
B
12

This will add entries to the context-menu to launch a command window that is automatically navigated to the directory you clicked.

Usage:

Right-click a folder icon (or the empty background area inside an already open folder)
and click either "Open in Terminal" or "Open in Terminal (Admin)".

You can also right click files to execute them with a command window.
When the file is done running you are left with a command window that is navigated to the files directory.

enter image description here

Open_in_Terminal.reg

Windows Registry Editor Version 5.00

; Admin versions.

; Right click on a folder in a directory.
[HKEY_CLASSES_ROOT\Directory\shell\OpenCommandWindowHereAsAdministrator]
@="Open in Terminal (Admin)"
"Icon"="cmd.exe"
"HasLUAShield"=""
"Position"="middle"
[HKEY_CLASSES_ROOT\Directory\shell\OpenCommandWindowHereAsAdministrator\command]
@="cmd.exe /c powershell.exe -Command \"Start-Process cmd -Verb runas -ArgumentList '/k pushd \"%1\"'\""

; Right click on nothing in a directory, i.e. the "background" of the directory.
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCommandWindowHereAsAdministrator]
@="Open in Terminal (Admin)"
"Icon"="cmd.exe"
"HasLUAShield"=""
"Position"="middle"
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCommandWindowHereAsAdministrator\command]
@="cmd.exe /c powershell.exe -Command \"Start-Process cmd -Verb runas -ArgumentList '/k pushd \"%V\"'\""

; Right click on nothing in a library directory, i.e. the "background" of the library directory.
[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\OpenCommandWindowHereAsAdministrator]
@="Open in Terminal (Admin)"
"Icon"="cmd.exe"
"HasLUAShield"=""
"Position"="middle"
[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\OpenCommandWindowHereAsAdministrator\command]
@="cmd.exe /c powershell.exe -Command \"Start-Process cmd -Verb runas -ArgumentList '/k pushd \"%V\"'\""

; Right click on a file in a directory.
[HKEY_CLASSES_ROOT\*\shell\OpenWithCommandWindowAsAdministrator]
@="Open in Terminal (Admin)"
"Icon"="cmd.exe"
"HasLUAShield"=""
"Position"="middle"
[HKEY_CLASSES_ROOT\*\shell\OpenWithCommandWindowAsAdministrator\command]
@="cmd.exe /c powershell.exe -Command \"Start-Process cmd -Verb runas -ArgumentList '/k pushd \\\"%W \\\" && \\\"%1\\\"'\""

; Non-Admin versions.

; Right click on a folder in a directory.
[HKEY_CLASSES_ROOT\Directory\shell\OpenCommandWindowHere]
@="Open in Terminal"
"Icon"="cmd.exe"
"Position"="middle"
[HKEY_CLASSES_ROOT\Directory\shell\OpenCommandWindowHere\command]
@="cmd.exe /k pushd \"%1\""

; Right click on nothing in a directory, i.e. the "background" of the directory.
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCommandWindowHere]
@="Open in Terminal"
"Icon"="cmd.exe"
"Position"="middle"
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCommandWindowHere\command]
@="cmd.exe /k pushd \"%V\""

; Right click on nothing in a library directory, i.e. the "background" of the library directory.
[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\OpenCommandWindowHere]
@="Open in Terminal"
"Icon"="cmd.exe"
"Position"="middle"
[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\OpenCommandWindowHere\command]
@="cmd.exe /k pushd \"%V\""

; Right click on a file in a directory.
[HKEY_CLASSES_ROOT\*\shell\OpenWithCommandWindow]
@="Open in Terminal"
"Icon"="cmd.exe"
"Position"="middle"
[HKEY_CLASSES_ROOT\*\shell\OpenWithCommandWindow\command]
@="cmd.exe /k pushd \"%W\" && \"%1\""

This took a lot of effort to make so if you're feeling generous then feel free to send a paypal donation to help me overcome the PTSD of debugging and testing it :)

An uninstaller if you need one:

Open_in_Terminal_Remover.reg

Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\Directory\shell\OpenCommandWindowHereAsAdministrator]
[-HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCommandWindowHereAsAdministrator]
[-HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\OpenCommandWindowHereAsAdministrator]
[-HKEY_CLASSES_ROOT\*\shell\OpenWithCommandWindowAsAdministrator]
[-HKEY_CLASSES_ROOT\Directory\shell\OpenCommandWindowHere]
[-HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCommandWindowHere]
[-HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\OpenCommandWindowHere]
[-HKEY_CLASSES_ROOT\*\shell\OpenWithCommandWindow]
Balsamiferous answered 2/8, 2017 at 19:53 Comment(1)
Works for right-click on Desktop, dir on Desktop, Sidebar and dir or white-space in File Explorer - thank you! Very clean solnHardiness
C
12

If you are starting cmd from taskbar, this is what you need to do:

right click --> rightclick on Command Prompt --> Properties

enter image description here

Then in the properties window change the value of Start in:

enter image description here

This solution doesn't work for opening command prompt as administrator

Coed answered 18/5, 2018 at 2:6 Comment(3)
"Start in:" location under my Windows 10 does not work if it's an administrative prompt. -> ALWAYS opens in system32 for me.Philippa
@bshea You are right, I tried and got the same results. So the solution can only be used for non-admin command prompts.Coed
Yep.. was driving me nuts. use pushd per https://mcmap.net/q/80474/-how-can-i-open-a-cmd-window-in-a-specific-location - is best/easiest can find for admin prompt location setting..Philippa
E
11

Create a shortcut and edit the "Start In" property of the shortcut to the directory you want the cmd.exe to start in.

Excurvate answered 13/9, 2008 at 21:56 Comment(1)
As also mentioned in comments to other answers, this works with non-admin execution only. As also mentioned herein, the /k "pushd <dir>" solution works with both.Unreasoning
H
11

I just saw this question and cannot help to post my AutoHotkey script for cmd on Windows XP. You can spot the hot keys in the script. The nice thing is when your current windows is Explorer, the cmd will open in the path showing in the address bar.

I keep this script in a folder where I store all green tools (including AutoHotkey). For a new machine, I just copy the folder, double click the script to associate .ahk with AutoHotkey and create a shortcut in my startup folder. It is faster than installing PowerToys.

; Get working folder
GetWorkingFolder() {
    if WinActive("ahk_class ExploreWClass") or WinActive("ahk_class CabinetWClass") {
        ControlGetText, path, Edit1
        return %path%
    } else if WinActive("FreeCommander") {
        Send, {CTRLDOWN}{ALTDOWN}{INS}{ALTUP}{CTRLUP}
        Sleep, 100
        return clipboard
    } else {
        return "C:\"
    }
}

#IfWinActive,

#c::
    path := GetWorkingFolder()
    Run, %ComSpec%, %path%
    return

; PowerShell
#+C::
    path := GetWorkingFolder()
    Run, %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe, %path%
    return

#^c::
    Run, %ComSpec%, %temp%
    return

#!c::
    path := GetWorkingFolder()
    Run, %comspec% /k "%VS90COMNTOOLS%vsvars32.bat", %path%
    return

; irb
#!b::
    path := GetWorkingFolder()
    Run, c:\cygwin\bin\ruby /usr/bin/irb, %path%
    return

; Bash
#b::
    path := GetWorkingFolder()
    Run, bash --login, %path%
    return

; Paste in console
+INS::
    if WinActive("ahk_class ConsoleWindowClass") {
        WinGetPos, x, y, w, h, A
        MouseGetPos, mx, my
        ;MsgBox x=%x% y=%y% w=%w% h=%h% mx=%mx% my=%my%
        if (mx < 10)
            mx = 10
        else if (mx > w - 30)
            mx := w - 30

        if (my < 40)
            my = 40
        else if (my > h)
            my := h - 10

        MouseClick, right, mx, my
    }
    return

For anyone who is interested, you can find this script at rwin on github

Hemelytron answered 17/3, 2011 at 16:41 Comment(1)
It's now part of my windows tool set, you can find it here: code.google.com/p/rwintools. The script has also been updated to support windows 7. I am planning to add more document recently.Hemelytron
S
10

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

Southwick answered 18/10, 2008 at 21:3 Comment(0)
R
10

This answer is for windows 10.

Create a command prompt shortcut in the folder wherever you want, then right click on that shortcut type your target in start in field

and

Here you go

Ramification answered 10/7, 2019 at 19:6 Comment(2)
This doesn't work if you need elevated rights. See superuser.com/questions/1067901/…Cuirbouilli
IMHO this is the best answer as it requires the least amount of software to reach the goal.Erection
R
9

For windows 7 or later, inside the target folder address bar just type cmd. That is it. It will open up command prompt with path set to your present directory.

Rina answered 9/10, 2015 at 9:2 Comment(1)
this is nice idea and works, with just one exception: if it has sub folder named cmdHanhana
C
8

In File Explorer, press and hold the Shift key, then right click or press and hold on a folder or drive that you want to open the command prompt at that location for, and click/tap on Open Command Prompt Here option.

Carlenacarlene answered 9/2, 2016 at 14:1 Comment(0)
I
8

I see that there are multiple answers, some are quite complex :) , strange to see them. You just have to open any windows folder window, navigate to your desired folder and focus on address bar and enter "cmd" and press enter, you would be presented with new command prompt window directly with the folder path or location that we already navigated in windows folder window. In case you want to see these steps with clear images you can check out

how to open command prompt in a specific folder directly

Ingham answered 15/6, 2016 at 17:49 Comment(0)
B
8

Make the shortcut to cmd.exe with params /S /K pushd "C:\YOUR FOLDER\"

Buryat answered 24/3, 2017 at 17:57 Comment(0)
D
7

For windows : Select the folder which you want to open in command prompt - After selection, Keeping the 'Shift key' pressed. Right click there and choose option "open command window here"

Discovert answered 7/2, 2017 at 5:51 Comment(0)
P
7

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..

Peta answered 22/5, 2019 at 8:46 Comment(0)
B
6

In Windows Explorer - shift + right mouse click above folder "Open command window here" option show up in the menu. Or in language of your Windows version.

Bountiful answered 14/1, 2014 at 23:39 Comment(0)
T
6

<===||==========> On Windows 10 <==========||===>


Assuming that in File Explorer you have opened the target directory/folder, do this :

  1. Click on address bar, alternatively press Alt + A

  2. Now when address bar is highlighted, type cmd in the bar.

  3. Press Enter key


For a powershell window :

  1. Just press Alt + f + s + a
Thumbstall answered 2/7, 2021 at 15:32 Comment(0)
F
5

If you use Total Commander there is a field in the bottom for this. It shows the active directory you are currently in and will run the entered command in that directory.

Total Commander command line

Fruitage answered 27/2, 2014 at 23:47 Comment(0)
R
4

Right 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.

Revert answered 18/10, 2008 at 20:25 Comment(0)
O
4

There is a simplier way I know. Find cmd.exe in start menu and send it to Desktop as shortcut. Then right-click it and choose properties. You will see "Start in" box under the "Target". Change that directory as whatever you'd like to set. Click OK and start cmd.exe which is in your Desktop. In my opinion, it's a very easy and certain solution :)

Optimum answered 2/11, 2011 at 9:0 Comment(0)
I
4

This program always opens cmd.exe in the current path of your Explorer: https://github.com/jhasse/smart_cmd

You can also pin it to your taskbar and then use WindowsKey+[1-0] as a keyboard shortcut.

Installment answered 16/1, 2012 at 9:43 Comment(0)
P
4

With a Just-one-line file in batch:

START "Desire_Path" // Without quotes puth the location that you want to start in with cmd

Example (Open a text editor, place the code in there and save the file with a .bat extension):

START cd C:\Users

Then just double click on it

****Note: if you want the explorer to complete the task don´t put the CD command.

*To do the opossite:

In order for you to open a particular directory with the explorer.exe aplication while using cmd you can use the command START and the absolute route of the folder that you want to display.

Purchase answered 8/10, 2015 at 16:59 Comment(0)
V
4

This method is using cmd.exe and Send to shortcut so cmd.exe can open directory directly. This alternative method is in case of not having Open command window here in right click menu.

  1. Open 'File Explorer' and enter shell:sendto in location bar to navigate to Send to folder.
  2. Copy a Command Prompt shortcut or create a new shortcut .lnk file.
  3. Edit the properties of the shortcut and edit the target to %windir%\system32\cmd.exe /k cd /d and press 'OK' to save the change.
  4. Right click on a folder and expand Send to menu to use the cmd shortcut.

This shortcut should open a cmd window with directory selected by the right click.

This method should work under Window 7 and 10 at least. Name the shortcut as Command Prompt (cd) to specify the task of the shortcut.

Possible error messages:

  • Show 'The directory name is invalid.' if other than folder is selected.
  • Show 'The system cannot find the drive specified.' if the folder is not existed.
  • Show 'The filename, directory name, or volume label syntax is incorrect.' if multiple files are selected.

Little about shortcut: The directory would be automatically added to the end of the shortcut as a parameter when using under Send to, so the shortcut does not need to type in the directory.

Velarium answered 30/12, 2015 at 18:15 Comment(1)
i put "cmd.exe /s /k pushd" into the target (works also with network shares). you can also hit "advanced" and select "run as admin" to get an elevated one :)Danu
H
4

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.

Heeler answered 10/9, 2018 at 22:11 Comment(0)
B
3

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.

  • Create a new txt file and write the following code into it.
    @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)

  • Then type your bat file's name without its extension.
  • For instance:goto-myProjectName

Then it should take you to there.

Bassoon answered 19/5, 2018 at 7:26 Comment(0)
H
3

Another easy solution is to install Windows Terminal.

And then you automatically have "Open in Windows Terminal" when you right-click on a folder:

enter image description here

Hoeve answered 22/2, 2021 at 14:59 Comment(0)
G
2

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.

Grania answered 3/8, 2009 at 6:58 Comment(0)
U
2

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\""
Unreasoning answered 22/5, 2019 at 10:28 Comment(0)
R
1

In windows 10, you just need one click to get cmd in any folder. Just hold "shift + mouse right click " in your desire folder and cmd will open with your folder path.

Rechaba answered 27/5, 2017 at 1:21 Comment(0)
O
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":

enter image description here

Now you will get a little icon that you can click on, that will open PowerShell in the directory you are in: enter image description here

Onfroi answered 4/2, 2019 at 2:12 Comment(0)
P
1

Why that much of setup, for this simple matter, when your on the path in cmd just enter

start .

and press Enter

Pennyworth answered 7/6, 2019 at 7:2 Comment(2)
This is the content I came forBigeye
the question is the other way around when you are in file explorer and want to open terminal from there :), but good pointQueue
E
0

For a better experience using a terminal in windows system, cmder may help for a shortcut usage:

  1. Download cmder into your system
  2. Make shortcut
  3. type path_of_the_cmder /START target_path_wish_to_run

For an instance:

TARGET -> C:\Users\<username>i\AppData\Roaming\cmder\Cmder.exe /START C:\SOURCE\

Escadrille answered 15/4, 2017 at 13:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.