Does Verbs() support Submenus

Welcome Forums General PowerShell Q&A Does Verbs() support Submenus

Viewing 2 reply threads
  • Author
    Posts
    • #240575
      Participant
      Topics: 1
      Replies: 1
      Points: 17
      Rank: Member

      I have written a small piece of code which displays context menu forĀ  Devices&Printers. This does not work for menu items, which have submenus.

      $o = new-object -com Shell.Application
      $folder = $o.NameSpace(“shell:::{A8A91A66-3A7D-4424-8D24-04E180695C7A}”)
      foreach ($item in $folder.Items())
      {
      If ($item.Name -eq ‘iCR6X–1613950’)
      {

      # below does not print menu items which have submenu
      $item.Verbs()
      }
      }

       

      Any help is appreciated.

      Rohan

    • #240662
      Participant
      Topics: 4
      Replies: 480
      Points: 1,748
      Helping Hand
      Rank: Community Hero

      Both of these show the items I’d expect. They are not blank. Not sure why they would be blank for you?

      foreach ($item in $folder.Items()){$item.name}
      foreach ($item in $folder.Items())
      {
          foreach($verb in $item.verbs())
          {
              $verb.name
          }
      }
      

      Some of the output

      CutePDF Writer
      HP USB Optical Mouse
      Microsoft Print to PDF
      HP Compaq LA2405 Wide LCD Monitor
      Logitech H570e Mono
      Fax
      LifeCam Cinema
      
      &Network settings            
      S&ound settings              
      &Mouse settings              
      &Keyboard settings           
      &Regional                    
      S&ystem properties           
      Device &installation settings
      Po&wer options               
      Windows &Update  
      
    • #240734
      Participant
      Topics: 1
      Replies: 1
      Points: 17
      Rank: Member

      Thanks for the reply.

      You can easily reproduce this by using the below powershell script(https://devblogs.microsoft.com/scripting/use-powershell-to-work-with-windows-explorer/), which also does not display menu containing submenus.

      $o = new-object -com Shell.Application
      $folder = $o.NameSpace(“C:\Windows\System32”)
      $file=$folder.ParseName(“notepad.exe”)
      $file.Verbs()|select Name

       

       

Viewing 2 reply threads
  • You must be logged in to reply to this topic.