Hotkey to open cmd with administration rights in current folder from Explorer
Asked Answered
L

10

38

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?

Lifesaver answered 21/3, 2018 at 11:0 Comment(4)
You should ask this on Super UserHetti
Try this though tenforums.com/tutorials/…Hetti
Ok. I understandRowdy
Technically it's not a shortcut, but the accepted answer here works pretty well.Richey
I
67

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).
Indigenous answered 22/3, 2018 at 6:44 Comment(6)
Great! That's exactly what I need though the hotkey's combination isn't short :) ThanksRowdy
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 folderSlothful
point 2, alt+shift+enter is still opening cmd in non-admin mode, as alternatives to open cmd from current folder as adminGerundive
@vmrvictor, try alt+fma instead.Salade
Nope, the m in alt+fma does nothing. This answer is no longer correct by Windows 10 20H2.Nocturnal
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 commandsAnticipative
I
7
  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

Indigenous answered 21/3, 2018 at 11:13 Comment(3)
Ok. But I just wanted to find the shortkey for itRowdy
I can not switch disc from C:\ to D:\Kyle
@Kyle to switch to disk "D" just type d:, and then use the cd commandLallygag
K
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

Krutz answered 29/7, 2020 at 23:46 Comment(1)
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.Gaggle
P
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
Perri answered 15/10, 2022 at 4:28 Comment(0)
H
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].

Heliolatry answered 24/2, 2021 at 11:19 Comment(0)
I
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.

Inevitable answered 23/12, 2022 at 10:25 Comment(0)
M
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.

Mays answered 17/4, 2023 at 10:35 Comment(0)
A
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.

Appliance answered 4/6 at 9:5 Comment(0)
F
-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 ... 
Floydflss answered 30/7, 2020 at 0:24 Comment(0)
T
-1

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

Trovillion answered 2/2, 2022 at 8:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.