Executing CMD.exe with current path from context menu

Have a suggestion for "Everything"? Please post it here.
Post Reply
Cleoss
Posts: 27
Joined: Wed Mar 07, 2018 7:10 am

Executing CMD.exe with current path from context menu

Post by Cleoss »

void wrote: Image
For doing such repitative things easier I propose to add the commands "Open path with CMD" + "Open path with PowerShell" to context menu.

Image

The idea came to me from my fav Clover Explorer which also have in menu an opt to elevate PShell upto admin rights.

Image
NotNull
Posts: 5167
Joined: Wed May 24, 2017 9:22 pm

Re: Executing CMD.exe with current path from context menu

Post by NotNull »

That's already possible with the current version of Everything.
Will post it one of these days.
Cleoss
Posts: 27
Joined: Wed Mar 07, 2018 7:10 am

Re: Executing CMD.exe with current path from context menu

Post by Cleoss »

NotNull wrote:That's already possible with the current version of Everything.
Will post it one of these days.
Hehe, that's amazingly fast! :P Thx!!!
NotNull
Posts: 5167
Joined: Wed May 24, 2017 9:22 pm

Re: Executing CMD.exe with current path from context menu

Post by NotNull »

  1. Save REG file somewhere on your system
  2. If your Everything isn't installed in "C:\Program Files\Everything\Everything.exe", change the path in the REG file (or loose the icon)
  3. Import the reg-file

    Now, when you SHIFT-rightclick any file or directory in Everything's result list, you see something similar to this:
    2018-03-13 22_47_22-TEST.png
    2018-03-13 22_47_22-TEST.png (72.69 KiB) Viewed 5476 times
  4. That's it

Some remarks
  • No elevation needed to import the reg-file.All settings are Current User settings
  • This is actually a Explorer-context-menu. If you shift-rightclick a file or directory there, you will see the same "Extra" menu. THat why I put it in the extended context-menu (normally invisible)
  • This example is for CMD; Powershell is more of the same.
  • This is only for Directory (=normal folders).You could also add this to Folders for the special folders (but Everything ignores those) and drives. Regkeys: HKEY_CURRENT_USER\Software\Classes\Folder resp. HKEY_CURRENT_USER\Software\Classes\Drive
  • Everything has an option to add custom verbs, including keyboard shortcuts. That way you can - for example - use <Alt-C> to start CMD or <Shift-Alt-C> to start an elevated CMD in the right folder. Unfortunately, Everything had problems with the cascaded submenu's. If you don't use the "Extra" submenu, it will work.
  • I had trouble with "%V" on Win10 to indicate the folder-location of a file. Worked well on Win7 systems. Fallback was using "%1\..".
    (Need to figure out why this wasn't working, as I use this a lot.)
CONTEXTMENU.reg

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\*]

[HKEY_CURRENT_USER\Software\Classes\*\Shell]

[HKEY_CURRENT_USER\Software\Classes\*\Shell\MySubmenu]
"subcommands"=""
"Extended"=""
;--------[ SETTING ]-----------------------------------------
"MUIVerb"="Extra"
"Icon"="C:\\Program Files\\Everything\\Everything.exe"
;------------------------------------------------------------

[HKEY_CURRENT_USER\Software\Classes\*\Shell\MySubmenu\Shell]

[HKEY_CURRENT_USER\Software\Classes\*\Shell\MySubmenu\Shell\CMDelevate]
"HasLUAShield"=""
;--------[ SETTING ]-----------------------------------------
"MUIVerb"="CMD here (elevated)"
;------------------------------------------------------------
@=""

[HKEY_CURRENT_USER\Software\Classes\*\Shell\MySubmenu\Shell\CMDelevate\Command]
@="powershell.exe -Command \"Start-Process cmd.exe -argumentlist '/k pushd \"%1\\..\"'  -verb Runas\""



[HKEY_CURRENT_USER\Software\Classes\*\Shell\MySubmenu\Shell\CMDhere]
@=""
;--------[ SETTING ]-----------------------------------------
"MUIVerb"="CMD here"
"Icon"="imageres.dll,-5323"
;------------------------------------------------------------

[HKEY_CURRENT_USER\Software\Classes\*\Shell\MySubmenu\Shell\CMDhere\Command]
@="\"c:\\windows\\system32\\cmd.exe\" /k pushd \"%1\\..\""



;==============================================================




[HKEY_CURRENT_USER\Software\Classes\Directory]

[HKEY_CURRENT_USER\Software\Classes\Directory\Shell]

[HKEY_CURRENT_USER\Software\Classes\Directory\Shell\MySubmenu]
"subcommands"=""
"Extended"=""
;--------[ SETTING ]-----------------------------------------
"MUIVerb"="Extra"
"Icon"="C:\\Program Files\\Everything\\Everything.exe"
;------------------------------------------------------------

[HKEY_CURRENT_USER\Software\Classes\Directory\Shell\MySubmenu\Shell]

[HKEY_CURRENT_USER\Software\Classes\Directory\Shell\MySubmenu\Shell\CMDelevate]
"HasLUAShield"=""
;--------[ SETTING ]-----------------------------------------
"MUIVerb"="CMD here (elevated)"
;------------------------------------------------------------
@=""

[HKEY_CURRENT_USER\Software\Classes\Directory\Shell\MySubmenu\Shell\CMDelevate\Command]
@="powershell.exe -Command \"Start-Process cmd.exe -argumentlist '/k pushd \"%1\"'  -verb Runas\""



[HKEY_CURRENT_USER\Software\Classes\Directory\Shell\MySubmenu\Shell\CMDhere]
@=""
;--------[ SETTING ]-----------------------------------------
"MUIVerb"="CMD here"
"Icon"="imageres.dll,-5323"
;------------------------------------------------------------

[HKEY_CURRENT_USER\Software\Classes\Directory\Shell\MySubmenu\Shell\CMDhere\Command]
@="\"c:\\windows\\system32\\cmd.exe\" /k pushd \"%1\""




NotNull
Posts: 5167
Joined: Wed May 24, 2017 9:22 pm

Re: Executing CMD.exe with current path from context menu

Post by NotNull »

And if you want to uninstall:

Remove_ContextMenu.reg

Code: Select all

Windows Registry Editor Version 5.00

[-HKEY_CURRENT_USER\Software\Classes\*\Shell\MySubmenu]
[-HKEY_CURRENT_USER\Software\Classes\Directory\Shell\MySubmenu]

NotNull
Posts: 5167
Joined: Wed May 24, 2017 9:22 pm

Re: Executing CMD.exe with current path from context menu

Post by NotNull »

NotNull wrote:
  • Everything has an option to add custom verbs, including keyboard shortcuts. That way you can - for example - use <Alt-C> to start CMD or <Shift-Alt-C> to start an elevated CMD in the right folder. Unfortunately, Everything had problems with the cascaded submenu's. If you don't use the "Extra" submenu, it will work.
Here is that version (I thought that would be trivial, but maybe not...)

Assuming <Alt-C> and <Shift-Alt-C> are not used in Everything (default they are not) and you are not already using custom verbs (if you don't know what these are, you very likely do not use them) ...
  1. Import reg-file
  2. Stop Everything
  3. Add custom verb settings to Everything.ini
  4. Start Everything
  5. Done
Note: you can use the INJECT script to do steps 2,3 and 4 for you.

Now you can press <Alt-C> on a file or folder to open CMD in it. <Shift-Alt-C> for an elevated command prompt.
Or use Shift-Rightclick on the file/folder to show the CMD here /CMD here (elevated) options.

You can change the keyboard shortcuts through Menu:Tools > Options > Keyboard > Show commands containg "Verb". Verb 1 = cmd; verb 2 = elevated cmd.


CONEXTMENU2.reg

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\*]

[HKEY_CURRENT_USER\Software\Classes\*\Shell]

[HKEY_CURRENT_USER\Software\Classes\*\Shell\CMDelevate]
@=""
"Extended"=""
"HasLUAShield"=""
;--------[ SETTING ]-----------------------------------------
"MUIVerb"="CMD here (elevated)"
;------------------------------------------------------------

[HKEY_CURRENT_USER\Software\Classes\*\Shell\CMDelevate\Command]
@="powershell.exe -Command \"Start-Process cmd.exe -argumentlist '/k pushd \"%1\\..\"'  -verb Runas\""



[HKEY_CURRENT_USER\Software\Classes\*\Shell\CMDhere]
@=""
"Extended"=""
;--------[ SETTING ]-----------------------------------------
"MUIVerb"="CMD here"
"Icon"="imageres.dll,-5323"
;------------------------------------------------------------

[HKEY_CURRENT_USER\Software\Classes\*\Shell\CMDhere\Command]
@="\"c:\\windows\\system32\\cmd.exe\" /k pushd \"%1\\..\""



;==============================================================




[HKEY_CURRENT_USER\Software\Classes\Directory]

[HKEY_CURRENT_USER\Software\Classes\Directory\Shell]

[HKEY_CURRENT_USER\Software\Classes\Directory\Shell\CMDelevate]
"Extended"=""
"HasLUAShield"=""
;--------[ SETTING ]-----------------------------------------
"MUIVerb"="CMD here (elevated)"
;------------------------------------------------------------
@=""

[HKEY_CURRENT_USER\Software\Classes\Directory\Shell\CMDelevate\Command]
@="powershell.exe -Command \"Start-Process cmd.exe -argumentlist '/k pushd \"%1\"'  -verb Runas\""



[HKEY_CURRENT_USER\Software\Classes\Directory\Shell\CMDhere]
@=""
"Extended"=""
;--------[ SETTING ]-----------------------------------------
"MUIVerb"="CMD here"
"Icon"="imageres.dll,-5323"
;------------------------------------------------------------

[HKEY_CURRENT_USER\Software\Classes\Directory\Shell\CMDhere\Command]
@="\"c:\\windows\\system32\\cmd.exe\" /k pushd \"%1\""


Extra entries for EVERYTHING.ini

Code: Select all

custom_verb01=CMDhere
custom_verb02=CMDelevate
file_custom_verb_1_keys=8771
file_custom_verb_2_keys=9795
NotNull
Posts: 5167
Joined: Wed May 24, 2017 9:22 pm

Re: Executing CMD.exe with current path from context menu

Post by NotNull »

And for completion's sake, also the uninstall of ContextMenu2:
  1. Import Remove ContextMenu2.reg
    Remove ContextMenu2.reg

    Code: Select all

    Windows Registry Editor Version 5.00
    
    [-HKEY_CURRENT_USER\Software\Classes\*\Shell\CMDelevate]
    [-HKEY_CURRENT_USER\Software\Classes\*\Shell\CMDhere]
    
    
    [-HKEY_CURRENT_USER\Software\Classes\Directory\Shell\CMDelevate]
    [-HKEY_CURRENT_USER\Software\Classes\Directory\Shell\CMDhere]
    
  2. Inject settings in Everything.ini:

    Code: Select all

    custom_verb01=
    custom_verb02=
    file_custom_verb_1_keys=
    file_custom_verb_2_keys=
    
  3. Done
Post Reply