Many times we need to open the command line and then go to the appropriate directory for some action.
The general practice is to:
- Win+r Open the Run window
- Enter "cmd" carriage return to open command Line window
- If we are going to enter a bar sub-folder under the D-Disk Foo folder, the path is D:\foo\bar, first enter "D:" To enter the D-drive
- Enter "CD foo" and "CD Bar" in turn.
- or copy the folder address "D:\foo\bar" in the Address bar of the explorer, then enter the CD and paste the copied address to the back of the CD once (for long folder path, avoid one by one input)
If you need to do frequent command-line operations, each time through this way, it is bound to be very troublesome.
Shift-Right-click to open a command-line window
In fact, Windows has an inconspicuous feature is this, the same is to locate the D disk Foo folder in a bar sub-folder, for example, in the bar folder, the mouse in the space, hold down the SHIFT key, while right mouse, then in the right-click menu will appear a "Open command line menu option.
The path to the Open command-line window is now located in the directory where it was opened, where the command-line execution path was automatically located.
Open a command-line window as an administrator in the current directory
Although the above method is more convenient than the original method, but sometimes we need to operate in the command line administrator status, the command line window is required to open as an administrator, and the above method opens a normal command line window, at this time can not meet the requirements.
Similarly, we can open a command-line window that runs as an administrator by using the traditional method, either by locating the command-line window in the Start menu or by right-clicking on the C:\Windows\System32 to find the Cmd.exe and selecting "Run as Administrator". Then manually navigate to the desired folder.
Here's how to add a menu option to the right-click menu so that we can open a command-line window in a folder directly by right-clicking the mouse, which will make the job very easy.
Copy the following code to a text file, and then save it to Cmd.reg, note that the file suffix is reg, the registry file.
Windows Registry Editor Version 5.00; Created By:shawn Brink; http://www.sevenforums.com; Tutorial:http://www.sevenforums.com/tutorials/47415-open-command-window-here-administrator.html[-hkey_classes_ Root\directory\shell\runas][hkey_classes_root\directory\shell\runas]@= "Open cmd here as Admin" "Hasluashield" = "" "[ Hkey_classes_root\directory\shell\runas\command]@= "cmd.exe/s/k pushd \"%v\ "" [-hkey_classes_root\directory\ Background\shell\runas][hkey_classes_root\directory\background\shell\runas]@= "Open cmd here as Admin" "HasLUAShield "=" "[hkey_classes_root\directory\background\shell\runas\command]@=" cmd.exe/s/k pushd \ "%v\" "[-HKEY_CLASSES_ROOT\ Drive\shell\runas][hkey_classes_root\drive\shell\runas]@= "Open cmd here as Admin" "Hasluashield" = "" [Hkey_classes_ Root\drive\shell\runas\command]@= "cmd.exe/s/k pushd \"%v\ ""
Then double-click Run, pop up OK dialog box, click OK, then right click on the menu, there is an extra option to open the Command Line window as an administrator.
How to remove:
If one day you do not want this new option, please copy the following code, also save to a text file and then save as Remove.reg, double-click to run it. The option disappears and the menu returns to normal.
Windows Registry Editor Version 5.00; Created By:shawn Brink; http://www.sevenforums.com; Tutorial:http://www.sevenforums.com/tutorials/47415-open-command-window-here-administrator.html[-hkey_classes_ Root\directory\shell\runas][-hkey_classes_root\directory\background\shell\runas][-hkey_classes_root\drive\ Shell\runas]
Reference:http://www.sevenforums.com/tutorials/47415-open-command-window-here-administrator.html
How to quickly open a command line in a specified folder