Given a shell-extension CLSID, how do you find the implementing COM executable or DLL, and inspect its interfaces and members?

Viewed 258

I'm trying to figure out how File Explorer is able to open files in specific programs (context menu => open with), in particular installed UWP (Appx) Microsoft store apps, so that I can do this via Powershell.

See this thread for more details: How to open installed Microsoft Store apps from powershell?

In that thread we figured that you can launch installed UWP apps with arguments as follows:

Start-Process ('shell:AppsFolder\' + (Get-AppXPackage *Edge*)[-1].PackageFamilyName + '!App') -ArgumentList 'http://example.org https://wikipedia.org'

However, it seems that apps like "Photos" and "VLC" don't just open the files passed as arguments:

Start-Process ('shell:AppsFolder\' + (Get-AppXPackage *Photos*).PackageFamilyName + '!App') -ArgumentList 'C:\test\image1.png'
Start-Process ('shell:AppsFolder\' + (Get-AppXPackage *VLC*).PackageFamilyName + '!App') -ArgumentList 'C:\test\audio1.mp3'

The @mklement0 in the mentioned thread figured it's probably using COM: \HKEY_CLASSES_ROOT\jpegfile\ShellEx\{e357fccd-a995-4576-b01f-234630154e96} and %SystemRoot%\system32\PhotoMetadataHandler.dll

I have little experience with powershell / COM / DLL, so I'm not sure how to apply this information.

Questions

Is there a general way to open any file (any extension) passed as an argument (or otherwise) in a specified UWP app with Powershell (or C# as the last resort)?

And if that's easy to do can you also suggest a way to get a list of apps that support the specified file type / extension? (the same way File Explorer's "Open with" menu does it)

1 Answers

The following doesn't directly answer your question, but may still be helpful:

If you take a document-centric (file-type-centric) view:

  • You can directly pass a document (non-executable) to Start-Process, which uses the Windows shell's Open verb to process the document by default (the same operation you'd get if you double-clicked the document in File Explorer, for instance). The -Verb parameter allows you to select a different verb; e.g., to invoke the Edit verb on a batch file (*.cmd), which opens it for editing:

    Start-Process -Verb Edit some.cmd
    
  • To determine the available verbs for a given document (file type), use the following (note that the specified file needn't exist - what matters is the file-name extension):

    [System.Diagnostics.ProcessStartInfo] @{ FileName = 'foo.cmd' }
    
    • Note:
      • runas and runasuser are standard verbs that aren't file-type-specific and refer to performing an operation with elevation (as admin) and as a different (non-admin) user, respectively.
      • Open isn't always explicitly listed, but it is implicitly available - which in the case of file types without an associated application displays a dialog offering to select one or download one from the Microsoft Store (the dialog has no GUI element for dismissing (closing) it, but you can simply press Esc).
Related