We can right-click the mouse with Shift key to find the "Open command here" or "Open PowerShell window here" item to open the command line at current location.
But we often need to run the command line as an administrator, so you could register the following value to Windows Register to add a new item "Open command (as Admin) here" to Windows Explorer right-click menu.
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\Background\shell\runas] "Icon"="c:\\windows\\system32\\cmd.exe" "MUIVerb"="Open command (as Admin) here" "NoWorkingDirectory"="" [HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command] @="cmd.exe /s /k pushd \"%V\"" [HKEY_CLASSES_ROOT\folder\shell\runas] "Icon"="c:\\windows\\system32\\cmd.exe" "MUIVerb"="Open command (as Admin) here" "NoWorkingDirectory"="" [HKEY_CLASSES_ROOT\folder\shell\runas\command] @="cmd.exe /s /k pushd \"%V\""
Open the Notepad and paste the text of above, save the file as OpenCMDHere.reg, and then double click this file, and click the "Yes" button in the message box.
The meaning of the above code is that we will create a new Windows shell item called "runas" at folder and the empty space in a folder, and set the Icon and propmt text.
HKEY_CLASSES_ROOT\Directory\shell, the context menu when you right-click on a folder
HKEY_CLASSES_ROOT\Directory\background, the context menu when you right-click on the "background" empty space while in a folder
Then to define the running command of "runas" item:
cmd.exe /s /k pushd \"%V\"
That means to run the cmd.exe at the current working folder, the /k carries out the command specified by the following string so it executes the command pushd %V and since the only argument pushd accepts is a path it follows that %V a variable delivered by explorer that contains the path of the folder right clicked.
cmd command, https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490880(v%3dtechnet.10)
Pushd command, https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490978(v=technet.10)
我们可以在 Windows 的任意位置，通过 按下 Shift + 鼠标右键，来在当前位置启动 CMD 或 PowerShell。
但是，我们经常需要以管理员身份取运行 CMD，所以我们可以通过加载上述的值到注册表，来为右键菜单添加一个新的选项。将上述值保存到一个记事本中，并保存为 .reg 文件，然后双击运行，在后续提示中都选择 是，即可。