How does one trigger the "How do you want to open .* files from now on?" dialog via programming, command line, etc?
The Problem
When users are logging in for the first time several file extensions are set to open with the wrong default programs. I do not have permission to fix this via a GPO (long story short: corporate hierarchy).
Desired Outcome
I would like to place a script (powershell, vbscript, or batch) on the desktop that users can double click to set up all of the default applications. It will also set up some other default settings, but right now it's just the default apps that are giving me trouble.
What I have Tried
Setting the default apps automatically:
- "Assoc" and "FType". Seem to be, at best, very unreliable in Windows 10.
- Altering the registry. Only seems viable if the script can be run as an administrator.
Prompting a dialog so the users can quickly pick the correct defaults:
- "Default Apps" can be opened via "ms-settings:defaultapps", but there doesn't seem to be any way to open the "Default Apps By Filetype" window, let alone zoom in on the relevant file extension. At least not prior to Windows 11.
Arrived at Solution
I would like to launch the same dialog that appears when you click the "Change..." button in the "Properties" of a file.
I've determined that the program used to launch this dialog is C:\Windows\System32\OpenWith.exe.
The Roadblock
When I try to call OpenWith directly in the following format:
OpenWith.exe something.pdf
it opens the single-use "Open With" dialog:
I launched Process Explorer and determined whether clicking on the "Change..." button or launching via command line, Windows is starting "OpenWith.exe". For some reason one instance is changing how a specific file opens, while the other is causing system-wide changes.
The Roadblock
Does anyone know what needs to be done to make OpenWith.exe launch the version of itself that enables system-wide changes for default apps?
While in Process Explorer for OpenWith.exe I opened the "Strings" section to see if there were any bits of text that could be relevant command-line switches. The following seemed promising:
- Embedding
- NoOpenWith
- OpenWithSetDefaultOn
but made no difference when I used them on the command line.
Any insight you can offer would be greatly appreciated.