42

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?

4
  • 1
    You should ask this on Super User Commented Mar 21, 2018 at 11:02
  • Try this though tenforums.com/tutorials/… Commented Mar 21, 2018 at 11:03
  • Ok. I understand Commented Mar 21, 2018 at 11:32
  • Technically it's not a shortcut, but the accepted answer here works pretty well. Commented Mar 25, 2021 at 18:01

11 Answers 11

70

Complete shortcuts are listed here Link to the answer

  1. 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).
  2. 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.
  3. 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.
  4. 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.
  5. 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).
Sign up to request clarification or add additional context in comments.

6 Comments

Alt F S A opens me the powershell and I would prefer the command line, do we know any for the command line as admin on the current folder
point 2, alt+shift+enter is still opening cmd in non-admin mode, as alternatives to open cmd from current folder as admin
@vmrvictor, try alt+fma instead.
Nope, the m in alt+fma does nothing. This answer is no longer correct by Windows 10 20H2.
for those who don't want the powershell as the command shell, you can run the "cmd" program inside the powershell. Still the powershell window, but it will run the normal cmd commands
|
8
  1. Simply open cmd prompt from start as Run as Administrator,
  2. Copy the path where you want to execute using location/Address Bar
  3. Use CD space paste the address and press Enter

It will set to the desired folder path

3 Comments

Ok. But I just wanted to find the shortkey for it
I can not switch disc from C:\ to D:\
@FrenkyB to switch to disk "D" just type d:, and then use the cd command
5

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:

https://dkcool.tailnet.net/2019/05/add-open-admin-command-prompt-to-the-explorer-context-menu-in-windows-10/#tldr/

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:

https://superuser.com/questions/136838/which-special-variables-are-available-when-writing-a-shell-command-for-a-context

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.

https://github.com/DKCTC/windows-terminal-admin-shortcuts-registry

1 Comment

For opening an elevated cmd, the following command is a bit nicer: cmd /c start /min "" powershell -WindowStyle Hidden "start cmd \"/k cd /d %1\" -v runAs" You don't see the powershell window flash by using a minimized cmd to start the ps.
2

You can use powershell as well. It will be easy.

  1. Go to your file location
  2. PRESS Alt + F + S + A or Alt + f + s + a

Comments

0

I also needed the same so as to initiate my angular development test easier. However without running Command prompt as an administrator 'ng serve' won't work.

Had been using Git Bash for a while. Git Bash website

So I chose Gitbash to initiate the same, from the root folder of the app. [Right Clicked inside the root folder and Chose Git Bash Here]

and ran the command 'ng serve'. The build was compiled and I was able to access the port[4200].

Comments

0

If youre looking for a lazy solution which does not get you into powershell, you can use this nice script to run a batch file as admin. The only thing you have to do is add cmd.exe at the end. Place this batch file inside the folder you want and run it.

Comments

0

you can try to paste following command into .reg file and run:

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\AdminOpenCmd]
@="Open CMD here admin"
"Icon"="cmd.exe"
 
[HKEY_CLASSES_ROOT\Directory\Background\shell\AdminOpenCmd\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s,/k, pushd,%V' -Verb RunAs\""

This command could open a cmd window and change current path as admin, but this will flashed powershell window in start.

Comments

0

In the current folder, you can hold Alt and type F, S, A to bring up the File menu then open powerShell administrative . Alternatively, from the top menu of the current folder, you can click on "File" hover your mouse over "Open Windows powerShell," and then open an administrative PowerShell window. However, you cannot open an administrative Command Prompt (cmd) window in Windows 10 using this method.

If you require an administrative Command Prompt(cmd) instead of PowerShell, simply type "cmd" into the opened PowerShell window. This will transform the PowerShell window into an administrative Command Prompt.

Comments

0

for anyone need this on windows 11, right click on empty space inside the directory, hold 'CTRL & SHIFT' and select 'Open in terminal'.

Comments

-1

You can run a script in PowerShell something like below you can just have the syntax checked and can try implementing below sample

      powershell changepath.sh <path>
      
      changepath.sh
       CD $args[0]
        chmod rwxrwxrwx user ... 

Comments

-1

You can open the PowerShell by holding ALT and typing S->M->A. Then in the PS type cmd to move to cmd.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.