0

I would like to get the list of windows explorer context menu entitites (verbs) and commands behind it. Something like this:

Open with notepad++ | C:\Program Files\NOtepad++\NppShell_06.dll  
Add to archive      | C:\Program Files\WinRAR\rarext.dll
Play with VLC       | "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe"
   --started-from-file    --no-playlist-enqueue "%1"

and so on.

I've wrote PS script to get all commands from context menu (all the same I can do via C#):

$ErrorActionPreference= 'silentlycontinue'
Set-Location -LiteralPath HKLM:\SOFTWARE\Classes\*\shellex\ContextMenuHandlers;
$o = Get-ChildItem -LiteralPath HKLM:\SOFTWARE\Classes\*\shellex\ContextMenuHandlers;

foreach($obj in $o)
{
  $prop = (Get-ItemProperty $obj.PSChildName).'(default)';
  "-------------------------------------------------------------";

  try
  {
      $obj.PSChildName;
      $sub = (Get-Item -LiteralPath ("HKLM:\SOFTWARE\Classes\CLSID\" + $prop.ToString())).GetSubKeyNames();

      foreach($s in $sub)
      {
            (Get-ItemProperty -LiteralPath ("HKLM:\SOFTWARE\Classes\CLSID\" + $prop.ToString() + "\" + $s)).'(default)';
      }
  }
  catch
  {}

}

Output:

-------------------------------------------------------------
ANotepad++64
C:\Program Files\Notepad++\NppShell_06.dll
-------------------------------------------------------------
EPP
C:\Program Files\Windows Defender\shellext.dll
10.0.14393.1198
-------------------------------------------------------------
Open With
C:\Windows\system32\shell32.dll
-------------------------------------------------------------
WinRAR
C:\Program Files\WinRAR\rarext.dll
........

There is script to get verbs for specific file:

$o = new-object -com Shell.Application
$folder = $o.NameSpace("C:\Users\User\Documents")
$file=$folder.ParseName("file.txt")
$file.Verbs() | select *

Output:

Application Parent Name


               &Open
               &Print
               &Edit
               Edit with &Notepad++
               Check with Windows Defender...


               &Add to archive...
               Add &to "file.rar"
               Compress and email...
               Compress to "file.rar" and email
               .....

So, I do not know how to combine these solutions. Is there some command/elegant way to do what I want?

  • Have you tried looking at; https://stackoverflow.com/a/4467509/1838819? – DiskJunky Oct 20 '17 at 15:32
  • @Diskjunky Yes, I know how to read/write/delete from registry via C#, but it does not cover my goal – Ktulhu Green Oct 20 '17 at 15:52
  • I'm not actually clear on what it is that you want. If you can already ready the values from the registry, what is you question about? – DiskJunky Oct 20 '17 at 15:57
  • @DiskJunky I can get all commands for context menu in regisry, but I can not associate them with verbs. For example, I see, that command "C:\Program Files\Notepad++\NppShell_06.dll" is somewhere in context menu, but I do not know, that it is executed when I press (it is associated with) "open with notepad++" – Ktulhu Green Oct 20 '17 at 16:13
  • Take a look at the following post. There are links to two posts there that are doing the reverse (writing) of what you're looking for (reading); https://stackoverflow.com/a/1838889/1838819 – DiskJunky Oct 20 '17 at 16:16

0 Answers0