Though command prompt or cmd.exe is a popular tool used by Windows user to do things such as install packages, softwares, create directories etc. But sometimes it becomes cumbersome to use as its default location is set in C:\Users\username. We have to usaually change the current working directory using cd command which take effort.
We might need to frequently switch between current working directories as our softwares, exe files etc. are not at a single place. So using cd command everytime becomes time consuming. Also, generally cmd opens without admin privileges when we open it from start menu. And if we wat to perform some admin only action, we need to right click on cmd icon and then click on ‘Run as administrator’.
To save time in these actions, you will find the below workaround useful, as it will allow you to open cmd at a particular directory with just a click.
Here are the steps:
Step 1: Open Notepad.
Step 2: Copy the following script in notepad:
Windows Registry Editor Version 5.00 [-HKEY_CLASSES_ROOT\Directory\shell\runas] [HKEY_CLASSES_ROOT\Directory\shell\runas] @="ElevatedCMD" "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] @="ElevatedCMD" "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] @="ElevatedCMD" "HasLUAShield"="" [HKEY_CLASSES_ROOT\Drive\shell\runas\command] @="cmd.exe /s /k pushd \"%V\"" [HKEY_CLASSES_ROOT\LibraryFolder\background\shell] @="none" [HKEY_CLASSES_ROOT\LibraryFolder\background\shell\runas] @="ElevatedCMD" "HasLUAShield"="" [HKEY_CLASSES_ROOT\LibraryFolder\background\shell\runas\command] @="cmd.exe /s /k pushd \"%V\""
Save this file as “file.reg” at any location and do not forget to select “All files (*.*)” while saving. This will create a windows registry file called “file.reg” at your selected spot.
Step 3: Now go to the location where you saved this file, and double click to run it. Click “Yes” in the confirmation message, and you are all done!
Now if you want to open cmd at any location with admin privileges, simply go to that location in Windows explorer, Then right Click anywhere and click on “ElevatedCMD”. This Will open cmd with that particular folder as current working directory.