Beginning from Windows Vista, unless when User Account Control (UAC) is disabled, there will be occasional need to open an elevated administrator command prompt window with full administrator rights.
When an elevated command prompt is opened, it will normally go to \Windows\System32\ folder by default. Since Windows Vista, Windows OS has built-in hidden function to show Open Command Prompt Here on the contextual menu of the folder so that users can easily open a command prompt shell at current location when browsing directories in Windows Explorer, File Explorer or Computer (aka My Computer) directly into the directory without having to type a lot of “cd” (change directory) command, especially when the directory is deeply nested and low in hierarchy.
With the following trick, it’s also possible to add a context menu option item permanently to right click contextual menu of folders in Windows Explorer, File Explorer (in Windows 10) and Computer to bring up a Open Command Window Here as Administrator option which will not only open a command prompt at current Windows Explorer location which you’re viewing at, but also run the command window in elevated mode with full administrator privileges after granting permission with UAC dialog.
To add a contextual menu item to the file system folders’ right click menu that launch an elevated command window here at current directory as administrator, simply download the following registry registration file.
Download open-admin-command-prompt-here.zip.
Unpack the archive and double click on elevated-command-here.reg file to apply the registry setting. You can also right click on the .reg file and select “Merge”. Click “Continue” on User Account Control “Windows needs your permission” pop-up dialog, and then confirm the Registry Editor modification request by pressing “Yes” when asked whether sure want to continue on window with message saying “Adding information can unintentionally change or delete values can causes components to stop working correctly. If you do not trust the source of this information in open-admin-command-prompt-here.reg, do not add it to the registry.
What the registry file is doing is shown in the code block below. You can also copy and paste the following code to a text editor, and save the file with a filename with .reg extension. Then double click on it to merge the values to the registry.
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\shell\runas] @="Open Command Window Here as Administrator" [HKEY_CLASSES_ROOT\Directory\shell\runas\command] @="cmd.exe /s /k pushd \"%V\""
Once merged, open Windows Explorer, Computer, Documents, Pictures, Music, or Games in Windows Vista Start Menu, then right click on any folder, and you will see Open Command Window Here as Administrator contextual item option which will bring you direct to the destination directory which you right click at or currently in with full admin rights. A pretty convenient and useful shortcut trick.
The trick works on Windows 10, Windows 8.1, Windows 8, Windows 7 and Windows Vista, and future Windows version.