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
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
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