Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 769
Артур Гудиев Avatar asked Mar 21 '18 11:03

Артур Гудиев


People also ask

How do I open Command Prompt with administrator privileges?

To start a command prompt as an administrator (alternative method) Click the Start charm. Type cmd, right-click the Command Prompt tile, and then click Run as administrator.


2 Answers

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).
like image 50
Franklin Jacob Avatar answered Sep 20 '22 17:09

Franklin Jacob


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

like image 30
DK_ Avatar answered Sep 21 '22 17:09

DK_