How to open an elevated Command Prompt from context menu in Windows

This article tells you how to add an Open Command Prompt here (Administrator) option to the right-click context menu for folders, desktop and to This PC (previously Computer) in any version of Windows, including Windows 10.

Launch an elevated Command Prompt from the Context menu

To add the Open Command Window Here (Administrator) option to the context menu for file system folders, use the following REG file:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\runas]
@="Open Command Window Here (Administrator)"

[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""

[HKEY_CLASSES_ROOT\directory\Background\Shell\runas]
@="Open Command Window Here (Administrator)"

[HKEY_CLASSES_ROOT\directory\Background\Shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""


To add the entry to Computer (My Computer) context menu, use the following REG file:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\runas]
@="Open Command Prompt (Administrator)"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\runas\command]
@="cmd.exe"

How to Use REG Files

Copy the above contents to Notepad, and save the file with .REG extension. Then right-click the REG file and choose Merge.

Screenshots

The User Account Control (UAC) elevation prompt is presented to the user when clicking on this context menu option.

Note that this REG file replaces the runas command in the registry, if one was added manually earlier – for example, if you added something like “Take Ownership” to the right-click menu.

About the author

Ramesh Srinivasan is passionate about Microsoft technologies and has a vast experience in the ITeS industry — delivering support for Microsoft's consumer products. He has been a Microsoft Most Valuable Professional [MVP], for 10 years in a row from 2003 to 2012 for his contribution in various Windows support forums.

%d bloggers like this: