- Hotkey to open cmd with administration rights in current folder from Explorer
- 5 Answers 5
- How can I open a command prompt in current folder with a keyboard shortcut?
- 12 Answers 12
- How to open Windows CMD so that it starts in the current folder? [duplicate]
- 9 Answers 9
- How do I open Windows CMD in explorer from the current folder?
- BAT file to open CMD in current directory
- 18 Answers 18
Hotkey to open cmd with administration rights in current folder from Explorer
In Explorer sequence Shift+F10 -> open command window here opens cmd in current directory.
Is there any way to do the same via shortcuts to launch cmd with administration rights?
5 Answers 5
Complete shortcuts are listed here Link to the answer
- Right-click Start & choose Command Prompt or Command Prompt (Admin) from the Quick Link menu. You can also use keyboard shortcuts for this route: Windows key + X, followed by C (non-admin) or A (admin).
- Type cmd in the search box, then press Enter to open the highlighted Command Prompt shortcut. To open the session as an administrator, press Alt+Shift+Enter.
- From File Explorer, click in the address bar to select its contents; then type cmd and press Enter. That opens a non-admin Command Prompt session in the current folder.
- In a File Explorer window, hold down Shift as you right-click on a folder or drive. That opens a non-admin Command Prompt session in the selected location.
- To open an administrative Command Prompt window in the current folder, use this hidden Windows 10 feature: Navigate to the folder you want to use, then hold Alt and type F, S, A (that keyboard shortcut is the same as switching to the File tab on the ribbon, then choose Open command prompt as administrator).
- Simply open cmd prompt from start as Run as Administrator,
- Copy the path where you want to execute using location/Address Bar
- Use CD space paste the address and press Enter
It will set to the desired folder path
I added the commands to the Explorer context menu in the registry for the background, folders, and files.
I know that you wanted a keyboard shortcut. I am hoping that you can use and adapt the commands and use the existing Windows shortcut system that allows you to set keyboard shortcuts.
Here is a link to an article that has the commands and a link to a ZIP with a REG file:
Adding to the Windows registry:
For the folder context-menu: (right-clicking on a folder in an explorer window)
powershell -WindowStyle Hidden «start cmd \»/k cd /d %1\» -v runAs»
For the background context-menu: (right-clicking on the background of an explorer window):
powershell -WindowStyle Hidden «start cmd \»/k cd /d %V\» -v runAs»
For the file context-menu: (right-clicking on a file in an Explorer window):
powershell -WindowStyle Hidden «start cmd \»/k cd /d %w\» -v runAs»
Here is a link to an article about the shell variables:
EDIT:
I added keyboard shortcuts using Shift+F10, Shift+Context menu key, or Shift-Right click, and then a given letter for the desired option, which you can modify in the registry. I put all of the files onto GitHub at the link below.
How can I open a command prompt in current folder with a keyboard shortcut?
How can I open a command prompt in current folder with a keyboard shortcut in Windows 7?
Is there any way to implement this?
I think Autohotkey could do this, but don’t know how.
12 Answers 12
Use this keyboard shortcut: Shift + Menu , W , Enter
Shift + Menu (alternatively, Shift + F10 ), (opens extended right-click menu in current folder)
W (selects «Open Command Window Here»),
The Menu key refers to the special key introduced by Microsoft, usually to the right of the right Win key.
This shortcut is available on a default installation of Windows (7) without any 3rd party software.
The AHK way. You just need to press Win + C (or whatever you want to define it as.):
As a bonus, the script above also creates a new text file with this shortcut: Win + T
Press Alt + D , type cmd and press Enter . For more details see blog post here.
the native way to do something similar in windows7 is to hold down shift while pressing the right mouse onto the folder you want to «command prompt» to and a new menu item will appear in your context menu offering you exactly that: «open command prompt here».
if you want pure keyboard action then you have to do this:
- open regedit
- go to HKEY_CLASSES_ROOT\Directory\shell\cmd and rename the Extended key to Extended_save
- go to HKEY_CLASSES_ROOT\Drive\shell\cmd and rename the Extended key to Extended_save`
this adds the «open command window here» entry to the context menu permanently. you can trigger this entry by pressing:
- alt
- let go, context menu opens
- press the «underscored» character of the «open command window here» entry or go down with your cursor keys and hit enter
the name of the menu entry is labled according to the language of your OS.
an alternative route is to do this:
- open the folder you want in the command prompt via the explorer
- f4
- ctrl a
- ctrl c
- win r
- cmd /k cd ctrl v enter
which grabs the current path from the address bar of explorer and executes cmd /k cd PATH . with autohotkeys you can do the same, but i do not know autohotkeys.
If you are using Windows 8/10, there is a faster and original way :
Just three key and type twice , without help of another program.
As of the latest Windows 10 update, Leftium’s answer’s Shift + Menu , W method no longer works. However, a small modification can present a workaround, albeit with a few more keystrokes.
The problem is that Command Prompt is no longer available in the Extended Right-Click Menu. Instead, you now have Windows Powershell.
Shift + Menu , S opens up Windows Powershell in the target folder. Once in Windows Powershell, type cmd then press Enter.
This will give you access to Command Prompt within Windows Powershell.
Ashwin Nanjappa’s method of Ctrl + L , type cmd then press Enter works. However, it is elegant only if you do not intend to return to the Windows Explorer window to continue navigating among directories. Unfortunately the method brings your cursor in Windows Explorer away from the main window and requires a number of Tab keystrokes to get it back to where you can navigate folders using the arrow keys. This can be frustrating as there is limited visual confirmation when you are pressing those Tab keystrokes.
Whereas Windows Powershell does work in most ways identically to Command Prompt, I have encountered at least one case in which Windows Powershell was erroneously misreading my @tags (when I was generating javadocs) and not producing the desired result. By typing cmd then Enter within Windows Powershell, you can use Command Prompt instead which overcomes such issues.
How to open Windows CMD so that it starts in the current folder? [duplicate]
When I’m working in a folder in Windows Explorer, sometimes I have a need to run some CMD command in this folder.
How do I open the command line from a current folder, so the console opens in the current directory?
I work in D:\Apps\Test . I would like to have a possibility to open a command prompt with the same context (meaning: D:\Apps\Test ), so I don’t have to navigate to this folder again within a console, ie. so it opens cd ‘d to the current location.
EDIT: The solutions from this topic do not work for me, what’s why I asked a separate question.
9 Answers 9
You can also shift-right-click in a folder, and notice a new entry in the context menu (Open command window here):
Enter cmd in explorer’s address bar & press enter
How do I open Windows CMD in explorer from the current folder?
Enter cmd in the explorer address bar and press Enter
Hold down shift while right-clicking anywhere in the folder. You will be presented with an option to «Open Command Window Here».
You can also shift + right click on any sub folder and open a command window there as well.
If you’re a GUI kind of person, holding Shift during right-click makes «Open command window here» appear in the context menu. You can try it on current or nested folders.
I use the ContextConsole Shell Extension. When you make a right click you get an option to run a command prompt and run a command prompt as admin (elevated) to do system tasks.
If you don’t mind using third-party extensions, the free ClassicShell allows adding a custom toolbar to Windows Explorer.
The image shows the configuration that I currently use. The button on the far right opens a console window to the current folder. This is how you can get it.
- Install the Classic Explorer part of ClassicShell
- Open a new Explorer window. You should now see an additional toolbar right below the address bar.
- Right-Click into the toolbar and select ‘Classic Explorer Settings’
- In the opening dialog window, check the ‘Show all settings’ checkbox.
- Go to the ‘Toolbar Buttons’ tab to configure the layout of the custom toolbar. Feel free to throw out any buttons that you don’t like.
- Add a ‘Custom’ button from the list on the right. Double-click the newly added button in the list on the left and enter cmd in the ‘Command’ field.
I am usually not a big fan of third-party extensions, but I found this one to be very useful, especially for this particular use case.
BAT file to open CMD in current directory
I have many scripts which I interact with from the command line. Everytime I need to use them, I have to open a command line window and copy+paste and CD to the path to the directory they are in. This is tedious (they are in a rather deep file system, so typing out the full path is a pain, copy+paste is better but not much). I tried to create a .BAT file that I could double-click on that would open a new command-line window in the folder the .bat file exists in but it does not work. It opens a new window, but the working directory is not the directory that .bat file is in. Here’s what I’ve got after much googling (My cmd skills ain’t so great):
I know from when I used Linux that Konqueror had a «Command-line window here» feature, and that’s the effect I’m trying to get on Windows.
18 Answers 18
Create a file named open_dos_here.cmd with the following lines:
Put this file at any folder. Then, go to your Send To folder ( Win + E ; Alt + D ; shell:sendto ; Enter ). Create a shortcut to point to this open_dos_here.cmd
Then, in any folder, select any file or sub-folder. Right-click and select «Send To» and then select open_dos_here.cmd to open the DOS in that folder.
p1″ – Alvin SIU Dec 19 ’10 at 15:33
d1 is to extract only the drive letter of %1 (e.g. C:). This goes to C drive. The 2nd line cd to %
p1 which is the path of %1 (i.e. \myFolder). After going to this directory, simply call the cmd to open the DOS command prompt. – Alvin SIU Aug 23 ’14 at 9:12
you probably want to do this:
this will set your current directory to the directory you have the batch file in
dp0′ is simply the variable that holds the path the currently executing batch file is located in — therefore executing this command will take you to that directory (apparently this variable is only available from a batch file, which makes sense) – Chris Dec 15 ’10 at 15:51
dp0″ With the double-quotes? – Paul Tomasi Dec 19 ’10 at 3:59
dp0′ – Chris Jan 11 ’11 at 15:23
You can just enter cmd into the address bar in Explorer and it starts up in that path. Likewise for PowerShell.
There’s more simple way
As a more general solution you might want to check out the Microsoft Power Toy for XP that adds the «Open Command Window Here» option when you right-click: http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx
In Vista and Windows 7, you’ll get that option if you hold down shift and right-click (this is built in).
I’m thinking that if you are creating a batch script that relies on the Current Directory being set to the folder that contains the batch file, that you are setting yourself up for trouble when you try to execute the batch file using a fully qualified path as you would from a scheduler.
Better to add this line to your batch file too:
unless you are fully qualifying all of your paths.
The simplest command to do this:
start
You can always run this in command line to open new command line window in the same location. Or you can place it in your .bat file.
Most simple way in explorer is to Shift + right mouse click on the folder or on an empty space in the folder and click on Open command prompt here .
CMD will then start in that folder
I must say, I’m not sure if it works for Windows Vista and below, but it surely works for Windows 7, 8, 8.1 and 10.
Another solution is to use a shortcut file to cmd.exe instead of a batch file.
Edit the shortcut’s start in property to %
You achieve the same thing, except it has the Cmd icon (and you can change this).
Some people don’t like clicking on batch files without knowing what’s in them, and some corporate network drives have a ban on .bat files.
You could add a context menu entry through the registry:
Navigate in your Registry to HKEY_LOCAL_MACHINE/Software/Classes/Folder/Shell and create a key called «Command Prompt» without the quotes.
Set the default string to whatever text you want to appear in the right-click menu.
Create a new key within your newly created command prompt named «command,» and set the default string to
You may need to add %SystemRoot%\system32\ before the cmd.exe if the executable can’t be found.
- The changes should take place immediately. Right click a folder and your new menu item should appear.
Referring to answer of @Chris,
We can also go to parent directory of batch file and run commands using following
To understand working of command cd /d %
dp0.. please refer below link
A bit late to the game but if I’m understanding your needs correctly this will help people with the same issue.
Two solutions with the same first step: First navigate to the location you keep your scripts in and copy the filepath to that directory.
- Click «Start»
- Right-click «Computer» (or «My Computer)
- Click «Properties»
- On the left, click «Advanced System Settings»
- Click «Environment Variables»
- In the «System Variables» Box, scroll down and select «PATH»
- Click «Edit»
- In the «Variable Value» field, scroll all the way to the right
- If there isn’t a semi-colon (;) there yet, add it.
- Paste in the filepath you copied earlier.
- End with a semi-colon.
- Click «OK»
- Click «OK» again
- Click «OK» one last time
You can now use any of your scripts as if you were already that folder.
Second Solution: (can easily be paired with the first for extra usefulness)
On your desktop create a batch file with the following content.
This will open a command window like what you tried to do.