During the course of making adjustments to various Windows settings, you may need to open command prompt as administrator dozens of times. Here’s how to do that quickly and at the right path.
Command prompt is the way to do operations in Windows using the command line, that is, by typing or pasting commands instead of using the user interface.
Opening a command prompt is as simple as typing cmd into Start search and pressing Enter. However opening it at the right path, or opening it as administrator may be tricky for some inexperienced users. Similarly, opening it as administrator and at the right path may be even trickier. Here are some ways to open command prompt as administrator at the right path.
Open cmd prompt at the right path
The easiest way to do this is to simply open any folder path in File Explorer. Then focus on the address bar by clicking on it or press Alt+D. Type cmd and press Enter. Command prompt will open at the folder you are currently browsing in Explorer.
Open cmd prompt as administrator
In current versions of Windows 10, Microsoft removed the Open command window here option from the File menu of the Explorer Ribbon. So adding it to the context menu is even more important than ever.
In Start search, type cmd and press Ctrl+Shift+Enter to open the selected item, Command Prompt as administrator. To open command prompt as administrator at a specific path, copy the text below into Notepad or your favorite text editor and save it as a .REG file.
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\shell\OpenAdminCmd] @="Command Prompt (Administrator)" "Icon"="cmd.exe" [HKEY_CLASSES_ROOT\Directory\shell\OpenAdminCmd\command] @="powershell -windowstyle hidden -c start-process -FilePath cmd.exe -ArgumentList '/s,/k,pushd,%V' -verb runAs" [HKEY_CLASSES_ROOT\Directory\Background\shell\OpenAdminCmd] @="Command Prompt (Administrator)" "Icon"="cmd.exe" [HKEY_CLASSES_ROOT\Directory\Background\shell\OpenAdminCmd\command] @="powershell -windowstyle hidden -c start-process -FilePath cmd.exe -ArgumentList '/s,/k,pushd,%V' -verb runAs" [HKEY_CLASSES_ROOT\Drive\shell\OpenAdminCmd] @="Command Prompt (Administrator)" "Icon"="cmd.exe" [HKEY_CLASSES_ROOT\Drive\shell\OpenAdminCmd\command] @="powershell -windowstyle hidden -c start-process -FilePath cmd.exe -ArgumentList '/s,/k,pushd,%V' -verb runAs"
Then double-click the REG file to merge it into the Registry. If you want to know more about REG files, see this article. This will add a verb Command Prompt (Administrator) to the context menu of a folder, the directory background menu, drives and even your Desktop right click menu.
The best thing about it is that it will also work on network paths. When you use it on a network path, a drive letter will be automatically mounted at the directory path on the network where you invoked it. When you type Exit to close the Command Prompt, the drive letter will be disconnected (unmapped) automatically.