CMDer / ConEmu - Explorer current directory location - windows

I have right click integration with CMDer to pop up a console, but it's defaulting to my user directory instead of the directory I performed the right click in. If you press Win+R and run cmd, or hold shift and right click to open a command prompt from the context menu; the command prompt opens up at that location. I've been able to get CMDer/ConEmu to pick up on that use it, however it seems to be a plain command prompt, no additional features supported.
Ideally I could elevate to run as admin, have tried -new_console:a in the integration settings menu with no luck.

You can go to Settings > Integration and set this in command field (upper section).
{bash} -cur_console:n:d:"%V"
%V is used to pass the current directory you are in.
After that you just need to hit the Register button in the upper section.

AFAIK CMDer forced your active directory to the user profile. Bare ConEmu do not do that. That's because cmder initialization scripts.
However without precise description hire do you set up your menu item (screenshot) and example of the directory you are trying it's impossible to be sure.

I solved the problem modifying the command syntax in registry. For example, it would look like that for the directories:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\Cmder]
#="Cmder Here"
"Icon"="C:\\tools\\cmder\\icons\\cmder.ico"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\shell\Cmder\command]
#="\"C:\\tools\\cmder\\Cmder.exe\" \"%V\""
You can fix this for drives as well. Don't forget about Background section so you can use the menu option from blank space in Explorer.
To run the shell in elevated mode you may add "*" (asterisk) before the command in tasks setup, like this:
Here is the full .reg file employing the fix. Just replace the path with your cmder installation and enjoy.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Drive\Background\shell\Cmder]
#="Cmder Here"
"Icon"="C:\\tools\\cmder\\icons\\cmder.ico"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Drive\Background\shell\Cmder\command]
#="\"C:\\tools\\cmder\\Cmder.exe\" \"%V\""
[HKEY_CLASSES_ROOT\Drive\shell\Cmder]
#="Cmder Here"
"Icon"="C:\\tools\\cmder\\icons\\cmder.ico"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Drive\shell\Cmder\command]
#="\"C:\\tools\\cmder\\Cmder.exe\" \"%V\""
[HKEY_CLASSES_ROOT\Directory\Background\shell\Cmder]
#="Cmder Here"
"Icon"="C:\\tools\\cmder\\icons\\cmder.ico"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\Background\shell\Cmder\command]
#="\"C:\\tools\\cmder\\Cmder.exe\" \"%V\""
[HKEY_CLASSES_ROOT\Directory\shell\Cmder]
#="Cmder Here"
"Icon"="C:\\tools\\cmder\\icons\\cmder.ico"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\shell\Cmder\command]
#="\"C:\\tools\\cmder\\Cmder.exe\" \"%V\""
P.S. It just struck me that %CMDER_ROOT env var may be used instead of the absolute path.

In my case worked by passing in the command arguments: /START "%folder%"

In the newer versions of cmder registering the right-click is enough.
Open the command prompt where cmder.exe exists. Then enter:
.\cmder.exe /REGISTER USER

In the newer version just go to Settings -> Integration -> Register -> Save Settings.
Note click the first register button of the upper section and then save the setting and its done, go to folder where you want to open the application press and hold shift key and right click and will appear ComEmu Here in dialog box.
It's for the latest versions.

Related

"Open git bash here" and "Open command prompt here" disappeared from Windows explorer context menu

Short of re-installing git or editing the relevant registry key that adds context menus to the shell myself, I was wondering if there was another way to bring back the "Git Bash Here" and "Open command window here" menus?
I am using Windows 7 Home Premium 64-bit.
Checkout this SO question:
Context menu for right click on folders in left panel of Windows
Explorer or on background of a directory in right panel:
HKEY_CLASSES_ROOT\Directory\Background\shell if you are administrator
HKEY_CURRENT_USER\Software\Classes\directory\Background\shell if you are a normal user
Context menu for right click on folders in right panel of Windows
Explorer:
HKEY_CLASSES_ROOT\Directory\shell if you are administrator
HKEY_CURRENT_USER\Software\Classes\directory\shell if you are a normal user
Context menu for any file:
HKEY_CLASSES_ROOT\*\shell if you are administrator
HKEY_CURRENT_USER\Software\Classes\*\shell if you are a normal user
In all cases:
add a new key under "shell", naming it as you want to name the
context menu item
add a new key inside this key, named command (mandatory name)
edit the "default" property in "command" to
myprogrampath\path\path\executable.exe %1 to pass the file path and
name of the selected file to your custom program
Update:
So I did a little more research into where the actual git bash and git gui context menu items were stored in the registry. I exported the keys that I had in my registry into a .reg file:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\git_shell\command]
#="\"C:\\Program Files\\Git\\git-bash.exe\" \"--cd=%1\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\git_gui\command]
#="\"C:\\Program Files\\Git\\cmd\\git-gui.exe\" \"--working-dir\" \"%1\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\git_shell\command]
#="\"C:\\Program Files\\Git\\git-bash.exe\" \"--cd=%v.\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\git_gui\command]
#="\"C:\\Program Files\\Git\\cmd\\git-gui.exe\" \"--working-dir\" \"%v.\""
In addition to the answer with the theory and the minimal example see the examples for Git (and not only) with user-friendly names, shortcut keys (& in a user-friendly name) and icons in the "win-registry-snippets" repository

Adding batch script to Windows 8 context menu

I saw some other questions about this here, but still got nothing working for what I want.
I want to right click the empty space of a folder, and see a menu for executing a batch file for the current folder.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\treeFiles]
#="Execute treeFiles"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\shell\treeFiles\command]
#="C:\treeFiles.bat \"%V\""
#="C:\\treeFiles.bat -d \"\"%V\"\""
With the above, I can only see the item when I right-click a folder (not the empty space), and the batch will execute relative to it's self path, not the current folder.
Any idea how to fix?
Use this instead:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\treeFiles]
#="&Execute treeFiles"
"Icon"="%SystemRoot%\\System32\\shell32.dll,71"
[HKEY_CLASSES_ROOT\Directory\Background\shell\treeFiles\command]
#="C:\\treeFiles.bat \"%V\""

enable get bash here/get gui here on Windows [duplicate]

How to add a context (aka right click) menu to the windows explorer that, when clicked, opens the git-bash console in the current explorer folder?
Step 1. On your desktop right click "New"->"Text Document" with name OpenGitBash.reg
Step 2. Right click the file and choose "Edit"
Step 3. Copy-paste the code below, save and close the file
Step 4. Execute the file by double clicking it
Note: You need administrator permission to write to the registry.
Windows Registry Editor Version 5.00
; Open files
; Default Git-Bash Location C:\Program Files\Git\git-bash.exe
[HKEY_CLASSES_ROOT\*\shell\Open Git Bash]
#="Open Git Bash"
"Icon"="C:\\Program Files\\Git\\git-bash.exe"
[HKEY_CLASSES_ROOT\*\shell\Open Git Bash\command]
#="\"C:\\Program Files\\Git\\git-bash.exe\" \"--cd=%1\""
; This will make it appear when you right click ON a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\shell\bash]
#="Open Git Bash"
"Icon"="C:\\Program Files\\Git\\git-bash.exe"
[HKEY_CLASSES_ROOT\Directory\shell\bash\command]
#="\"C:\\Program Files\\Git\\git-bash.exe\" \"--cd=%1\""
; This will make it appear when you right click INSIDE a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\Background\shell\bash]
#="Open Git Bash"
"Icon"="C:\\Program Files\\Git\\git-bash.exe"
[HKEY_CLASSES_ROOT\Directory\Background\shell\bash\command]
#="\"C:\\Program Files\\Git\\git-bash.exe\" \"--cd=%v.\""
And here is your result :
I had a similar issue and I did this.
Step 1 : Type "regedit" in start menu
Step 2 : Run the registry editor
Step 3 : Navigate to HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\Background\shell. If you don't have the shell key, create one.
Step 4 : Right-click on "shell" and choose New > Key. name the Key "Bash"
Step 5 : Modify the value and set it to "open in Bash" This is the text that appears in the right click.
Step 6 : Create a new key under Bash and name it "command". Set the value of this key to your git-bash.exe path.
Close the registry editor.
You should now be able to see the option in right click menu in explorer
PS Git Bash by default picks up the current directory.
EDIT : If you want a one click approach, check Ozesh's solution below
The easiest way is to install the latest Git from here. And while installing, make sure you are enabling the option Windows Explorer Integration.
Once you are done, you will get those options in whenever you right click on any folder.
Hope it helps.
Here are the Registry exports (*.reg files) for Git GUI and Git Bash directly from the Windows installer —Git GUI:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\git_gui]
#="Git &GUI Here"
"Icon"="C:\\Program Files\\Git\\cmd\\git-gui.exe"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\git_gui\command]
#="\"C:\\Program Files\\Git\\cmd\\git-gui.exe\" \"--working-dir\" \"%v.\""
Git bash:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\git_shell]
#="Git Ba&sh Here"
"Icon"="C:\\Program Files\\Git\\git-bash.exe"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\git_shell\command]
#="\"C:\\Program Files\\Git\\git-bash.exe\" \"--cd=%v.\""
For detail about *.reg files, see “How to add, modify, or delete registry subkeys and values by using a .reg file” from Microsoft.
You can install git for windows or Github for windows , both give you the choice while installing to add this feature to your windows explorer. You can find it here:
Github for Windows
https://windows.github.com/
Git for Windows
http://git-scm.com/
As, #Shaswat Rungta said: "I think the question is more about how to add it after the installation is over."
On my PC(Windows 7) I think that the command "Git Bash here" disappeard after I installed Visual Studio 2017.
I fixt this by downloading and installing Git again.
NOTE: "When installing Git for Windows the context menu options are not 'on' by default. You will have to select them during the install." – #nbushnell
(I did this)
What worked for me was almost this, but with the following REGEDIT path:
HKEY_LOCAL_MACHINE/SOFTWARE/Classes/Directory/background/shell and here I created the key Bash, with the value of what I want the display name to be, and then created another key under this named command with the value as the path to git-bash.exe
I'm on Windows 10 and have a fresh git install that didn't add this automatically for some reason (git version 2.12.0 64bit)
Had a similar issue in adding "Start Command Prompt with Ruby" to context menu as it involves passing parameters along with the patch of cmd. Followed a similar procedure as the solution above
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Cmd With Ruby]
#="Cmd With Ruby"
"Icon"="C:\\Windows\\System32\\cmd.exe"
[HKEY_CLASSES_ROOT\*\shell\Cmd With Ruby\command]
#="\"C:\\Windows\\System32\\cmd.exe\" \"/E:ON /K
\"C:\\Ruby25-x64\\bin\\setrbvars.cmd\"\" \"--cd=%1\"\""
[HKEY_CLASSES_ROOT\Directory\shell\bash]
#="Cmd With Ruby"
"Icon"="C:\\Windows\\System32\\cmd.exe"
[HKEY_CLASSES_ROOT\Directory\shell\bash\command]
#="\"C:\\Windows\\System32\\cmd.exe\" \"/E:ON /K
\"C:\\Ruby25-x64\\bin\\setrbvars.cmd\"\" \"--cd=%1\"\""
[HKEY_CLASSES_ROOT\Directory\Background\shell\bash]
#="Cmd With Ruby"
"Icon"="C:\\Windows\\System32\\cmd.exe"
[HKEY_CLASSES_ROOT\Directory\Background\shell\bash\command]
#="\"C:\\Windows\\System32\\cmd.exe\" \"/E:ON /K
\"C:\\Ruby25-x64\\bin\\setrbvars.cmd\"\" \"--cd=%v.\"\""
When you install git-scm found in "https://git-scm.com/downloads" uncheck the "Only show new options" located at the very bottom of the installation window
Make sure you check
Windows Explorer integration
Git Bash Here
Git GUI Here
Click Next and you're good to go!
Usually git bash here can be run only on directories so you have to go up a directory and right click on the previous directory then select git bash here (of course on Windows OS).
Note: context menu inside a directory does not have a git bash here option.
Another option but using PowerShell script.
This is basically a PowerShell script which does almost the same as this answer (it also adds icon).
Create file (addOpenGitBashHereContextMenu.ps1), paste in the code below and run it from PowerShell.
You probably need to change exePath to point to your git executable.
Also change contextMenuText if you want to change the text in context menu.
$exePath = $env:USERPROFILE + '\scoop\apps\git\current\git-bash.exe'
$contextMenuText = 'Open Git Bash Here'
$regEntryName = 'git_shell'
$regPathShell = 'HKCU:\SOFTWARE\Classes\Directory\Background\shell'
$regPathContextMenu = $regPathShell + '\' + $regEntryName
$regPathCommand = $regPathContextMenu + '\command'
$user = $env:UserName
echo "Setting '$contextMenuText' context menu..."
echo " User name: '$user'"
echo " Register path: '$regPathCommand'"
echo " Executable path: '$exePath'"
# Key: shell
If (-NOT (Test-Path $regPathShell)) {
New-Item -Path $regPathShell
}
# Key: regEntryName
If (-NOT (Test-Path $regPathContextMenu)) {
New-Item -Path $regPathContextMenu -Value $contextMenuText
# Add Icon to context menu
Set-ItemProperty -Path $regPathContextMenu -Name 'Icon' -Value $exePath
}
# Key: command
If (-NOT (Test-Path $regPathCommand)) {
New-Item -Path $regPathCommand -Value $exePath
}
Try updating your git. For window user you can update your git via cmd by simply writing the command- "git update-git-for-windows".
When done, you can simply right click inside a directory where you want to open the gitbash and check if its showing "Gitbash here" or not. If it's not showing anything, try to look for "Show more options" there and click on it. Now, you may able to see it.
I ran into this problem installing Git-2.38.1-64-bit on a new Windows 10 Pro corporate laptop.
I tried several things ... and considered one of the regedit scripts (the moral equivalent of "Nurse - chainsaw!")... but resolved the problem by simply uninstalling and reinstalling Git (as "Admin").
Specifically:
Control Panel > Programs/Features > Uninstall Git
Reboot Windows
Reinstall Git-2.38.1-64-bit as "Admin"
Carefull check all the options, especially:
"Windows Explorer Integration: Git Bash Here, Git GUI Here
<= These are checked by default ... and I'm sure they were both "Y" on the initial install
I copied my .gitconfig ("C:\Users\USERNAME.gitconfig") from another PC
<= I don't believe this was "essential" ...but I thought I'd mention it...
Browse to a local Git repo and verify the Git context menus work
<= Success after reinstall!
I updated my git and I marked the option of "Git Bash Here"
I have already too many programs that want a spot on my PATH list. Rather than pollute my PATH list, I choose instead to add a symbolic link, from an elevated command prompt, like so.
mklink C:\bin\git-bash.exe "C:\Program Files\Git\git-bash.exe"
While there are exceptions, this works in the majority of cases, including, among others, the 7-zip CLI, selected SysInternals command line tools, the NuGet CLI, and many others.
As a bonus, having the Git Bash command line interface so readily accessible makes activating it from an open command prompt window trivial. With this improvement, I can probably live without yet another item on my context menu for directories.
In addition to the answers with the theory and the minimal examples see the example of the .reg file for Git (and not only, with the instruction) with user-friendly names, shortcut keys (& in a user-friendly name) and icons in the "win-registry-snippets" repository
Do Nothing.
Just open your git bash terminal and type in:
git update-git-for-windows
Once update is completed, this will automatically add "Git Bash here" into your context menu.
Refer this: https://stackoverflow.com/a/65467670
You can install TortoiseGit for Windows and include integration in context menu.
I consider it the best tool to work with Git on Windows.
Add the gitpath to the Environment-path variable (e.g. C:\Program Files\Git\cmd) by which you can access git from any folder using command line.
Use Shift + F10 to open the menu of options which appear when right clicked, and then click s to git bash here.

Windows shell add item to context menu when click on blank part of folder

Sorry if this has been asked before, I've been looking around and it's hard to find what I want.
I know how to add a context menu item to a folder like so:
[HKEY_CLASSES_ROOT\Folder\shell\console2]
#="Open Console2 Here"
[HKEY_CLASSES_ROOT\Folder\shell\console2\command]
#="C:\\Program Files\\Console\\console.exe -d \"\"%1\"\""
but, that only works for right clicking on a folder. I want it so that you can be inside the folder, and click a blank part of that folder and get the context menu item as well. I also tried HKEY_CLASSES_ROOT\Directory\shell as well, but it does the same.
I figured out the answer. The folder is actually Directory\Background, you have to add the empty string value of NoWorkingDirectory into it, and the %1 in the command becomes a %V
[HKEY_CLASSES_ROOT\Directory\Background\shell\console2]
#="Open Console2 Here"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\Background\shell\console2\command]
#="C:\\Program Files\\Console\\console.exe -d \"\"%V\"\""
Source:
saviert's comment at http://www.howtogeek.com/howto/windows-vista/make-command-prompt-here-always-display-for-folders-in-windows-vista#comment-57856
Console2 rocks. I added an 'Cmd here (Console2)' item to my explorer context menu.
Save the text below in a file named open-console2.reg then open it to import it to the Windows registry.
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\console2]
#="Cmd here (Console2)"
"NoWorkingDirectory"=""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\console2\command]
#="\"C:\\Program Files (x86)\\Console2\\Console.exe\" -d \"%V\"\\"
Bonus 'bash here' item (assumes you have a Console2 tab named 'bash').
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\console2_bash]
#="Bash here (Console2)"
"NoWorkingDirectory"=""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\console2_bash\command]
#="\"C:\\Program Files (x86)\\Console2\\Console.exe\" -t Bash -d \"%V\"\\"
I think the relevant part of the TortoiseSVN installer is here. Perhaps you can figure out all the necessary registry keys from that.
None of the above worked for me.
But this does (tested on Windows 7 Pro x64):
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\shell\Open console here\command]
#="u:\\users\\dave\\data\\bin\\Console2\\Console.exe cmd -r \"/k pushd %L\""
Replace the path with the path to your copy of console.exe (of course).
#Ben Voigt mentioned TortoiseSVN, you can also see WinMerge shell extension source code, or at last: create your own extension from scratch; I wanted to do something like this for XP but I have lots of other stuff to do now.
As a workaround, you can just open a folder in XP, and then select View->Explorer Bar->Folders, to have folder tree on left, and then you're able to right-click the folder (active folder gets hightlighted automatically).
Here it is if you prefer MinGW.
#!/bin/sh
reg add 'HKCR\Directory\Background\shell\sh' -d 'Open Bash window here'
reg add 'HKCR\Directory\Background\shell\sh\command' \
-d 'C:\MinGW\msys\1.0\bin\sh.exe -l'
printf 'cd -' >> ~/.profile
superuser.com/a/387273
According to my personal experience of Windows XP (SP3), you can open Console2 inside the current directory with a context menu entry using the following .reg file:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\shell\console2]
#="Console2 Here"
[HKEY_CLASSES_ROOT\Folder\shell\console2\command]
#="C:\Program Files\Console\console.exe -d \"%1\""
If you look at the key value inside regedit.exe , you should see:
C:\Program Files\Console\console.exe -d "%1"
instead of:
C:\Program Files\Console\console.exe -d ""%1""
The latter would open Console2 in its default start directory.
This can be achieved in XP as well.
First open the program Run with the Windows key + R,
and type Regedit in the textbox.
Press Enter.
In the Registry open the Key : HKEY_CLASSES_ROOT
and then : *
You will now see a key called : shell
Rightclick on shell and point to New.
Click in de menu on Key.
Now type a name of your choice which you want to appear in the Rightclick menu.
Rightclick on the name you chose, again point to New and click Key.
Now type : command
Click on command and in the right pane of the Registry doubleclick on (Default).
In the textbox Value Data, type the path to an application you want to open via the chosen name in the rightclick menu.
For example : "C:\Program Files\CCleaner\CCleaner.exe"
Then type after the path : %1,
and leave a space between the end of the path and %1
It should look like this :
"C:\Program Files\CCleaner\CCleaner.exe" %1
This way, it's possible to open any kind of application you want.
There's only one drawback,
you have to rightclick another file to see the chosen name with which you can open the application.
When you rightclick a folder this will not work.

How can I open a cmd window in a specific location?

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\"
(documentation)
Assuming that in File Explorer you have opened the target directory/folder, do this:
Click on address bar, alternatively press Alt+D
Now when address bar is highlighted, type cmd in the bar.
Press Enter key
You will notice that command prompt from that folder
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.
From Windows 7 up to some versions of Windows 10, it is very simple to open a command prompt anywhere you wish, without navigation using command "cd".
Try the following one.
Click the mouse's right button by holding Shift key .
It will produce an option like this. Then simply select the "Open command window here " option.
The latest versions of Windows 10 have replaced this feature with "Open Powershell here".
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.
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
Use the /K switch. For example
cmd /K "cd /d c:\WINDOWS\"
Will create a cmd window at the C:\Windows directory
Just write cmd in the address bar, it will open in the current folder.
In windows go to folder location in file explorer remove path and type cmd and press enter. and path will open in cmd.
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.
pushd command sets the current folder. so:
cmd /k "pushd D:\Music"
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.
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.
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.
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
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.
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]
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
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.
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.
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
Make the shortcut to cmd.exe with params /S /K pushd "C:\YOUR FOLDER\"
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"
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..
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.
<===||==========> 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 :
Just press Alt + f + s + a
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 :)
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.
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.

Resources