17

(Skip to the question by scrolling to the very bottom, but in this case don't blindly vote to close ...)

Yes, I know this topic has been regurgitated a number of times here, here and here, but I promise this is no duplicate. None of these help associating software with file extensions at a larger scale. In fact I found that - at least with Windows 10 (1803) - you can change the associations more conveniently, but neither the FileTypesMan (I tried version 1.83) trick nor the tools assoc and ftype in tandem worked.

All of these methods failed in that they produced - upon double-clicking a file of the type/extension in question - the RT-style dialog that offered me to "Keep using this app", having "Photos" as the default and then offering a list of potential candidate software to handle the file type below.

I'd like the software of my choosing to open these files without ifs and buts (and extra dialogs).


Example: I wanted SumatraPDF to open a range of ebook file types alongside PDF (defaulting to Edge) and IrfanView to open images. When the applications were installed I got plenty of notifications from Windows that the file associations had been reset. Well, so much for controlling what's going on on my system.

So I started IrfanView as administrator and had it set the file associations. Alas, the UserChoice column in FileTypesMan kept showing AppX43hnxtbyyps62jhe9sqpdzxn1790zetc, which at least on my system corresponds to the Photos (store) application shipping with Windows. For this example I will discuss .bmp files.

When trying to fix the UserChoice column by means of FileTypesMan I was confronted with an error message proclaiming that access was denied. Uhm okay ...

So I had Process Monitor show me what key was affected by the access denied error. Sure enough it pointed out the attempt to write values inside HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bmp\UserChoice. So I checked out the permissions on that key and saw nothing suspicious. But on closer inspection in the "Advanced Security Settings" dialog for the UserChoice key I saw this:

Advanced Security Settings

Since my days as system administrator at the university Deny ACEs have been a rare sight, though. Now, being acutely aware of ACE precedence rules inside ACLs it immediately dawned on me that this Deny ACE was the issue. It dominated the ACL for my user account.

A tool such as FileTypesMan would have to actively remove that ACE and then put it back after any manipulation. Evidently it doesn't do that (possibly a defect that I should report?). There's no other way I know of, with the possible exception of acquiring and enabling the backup and/or restore privilege (aka user right) - which amounts to sidestepping the ACL and ACEs (aka cheating through the means of an admin ;)).

Anyway, I was out of luck from that side.


Alas, I found a workaround that worked for IrfanView. However, the same workaround did not work for SumatraPDF and it involved tedious mouse-clicking (and therefore I am asking this question).

The workaround was as follows. Open the "Windows Settings" app, pick "Apps" and then choose the "Defaults Apps" item on the left hand side. Scroll down in the main pane and from the bottom choose "Set defaults by app".

Default Apps

From there find the application - in my case IrfanView - which you want to manage and hit the "Manage" button (after selecting the program of your choice).

IrfanView in the app list

Then a new list opens providing a relatively simple overview of the file extensions that are apparently supported by the program (my guess is that HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bmp\OpenWithProgids or some other registry setting plays a role here) and lets you change the current setting.

Pick a new program for the file extension

So all is fine, right? Well, nope. While IrfanView made that list for "Set defaults by app", SumatraPDF was nowhere to be found.

While the fact that SumatraPDF isn't listed there may well be the fault of SumatraPDF, this still doesn't excuse Windows from reverting settings I consciously make and fully intended to make.


So while that "Windows Settings" app clearly has the magic sauce to circumvent that Deny ACE, it still doesn't provide an easy way for me to associate any file extensions in batch to a software of my choosing.

Question

So given the situation described above: How can I associate arbitrary file extensions with arbitrary installed software of my choosing at a larger scale (i.e. pretty much in batch) and without tedious mouse-clicking orgies and without risking Windows 10 stepping in and reverting my consciously made choices?

0

4 Answers 4

6

Although at the beginning I was skeptical about the poster's problem, I am flabbergasted to find this monumental gaff by Microsoft.

All the cases I have examined where the problem didn't occur, were installed before Windows 10 version 1809. When I downloaded the 1809 versions of Windows 10 Enterprise (Business) and Windows 10 Pro (Consumer) and did a clean install in virtual machines, they had this ACL!

This ACL is a new addition and did not exist in prior versions. It is apparently only stored during a clean install, not during the upgrade to 1809 from a prior version. I don't know what brainstorm brought this on, but Microsoft apparently decided to force the use of its Photos app upon the world.

We developers have no other option but to adapt to this new situation. You would need to delete this new and blocking ACL.

If you are looking for a solution in the form of a .reg file that deletes the Set Value entry, I think you will need to delete the entire branch for .bmp and recreate it anew in order to get rid of it. Otherwise, changing permissions would require a script or an installation program.

Something like :

Windows Registry Editor Version 5.00

[-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bmp]

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bmp]
...
0
4
+50

You could make a list of file extensions and corresponding applications which the extension will be run by, for example in Excel, export it to .csv file and use the PowerShell script from the below link: https://gallery.technet.microsoft.com/scriptcenter/How-to-associate-file-3898f323

You can try to edit this script that it would read the .csv file and do proper extension-application assignment.

You should be careful when dealing with .exe extension, as changing its behavior may result in general problems with Windows. Changing all the extensions in a for loop should take no more than few minutes.

EDIT: As per comment the link has died, so I am pasting below the script:

Function AssociateFileExtensions
{
    Param
    (
        [Parameter(Mandatory=$true)]
        [String[]] $FileExtensions,
        [Parameter(Mandatory=$true)]
        [String] $OpenAppPath
    ) 
    if (-not (Test-Path $OpenAppPath))
    {
       throw "$OpenAppPath does not exist."
    }   
    foreach ($extension in $FileExtensions)
    {
        $fileType = (cmd /c "assoc $extension")
        $fileType = $fileType.Split("=")[-1] 
        cmd /c "ftype $fileType=""$OpenAppPath"" ""%1"""
    }
}

Save it as AssociateFileExtensions.psm1.

I've taken that from: https://web.archive.org/web/20201112024219/https://gallery.technet.microsoft.com/scriptcenter/How-to-associate-file-3898f323

0
2

Since this question keeps coming back at me by others, I wanted to update this with two links to tools that allow to achieve the same. Both named STFA for "Set File Type Association" and by the same author(s):

The method of getting rid of the restrictive DACL appears to be roughly equivalent to the method outlined by harrymc, which deletes the key and then creates it anew.

However, as it turns out from consulting the (PowerShell) code, the process of computing those hashes set inside the UserChoice subkey is the real Magic Sauce™ that makes it work. The DACL is just an annoying red herring. Failing to set the right hash, Windows will just tell you via notification it has reverted to some default.


Another method that I found uses dism to export the file type associations prepared on a given system, e.g. from cmd.exe with:

dism.exe /Online /Export-DefaultAppAssociations:%USERPROFILE%\Desktop\DefaultAssoc.xml

dropping the DefaultAssoc.xml onto your current users' desktop.

You can then later import it with dism and the corresponding switch /Import-DefaultAppAssociations:... on a system where you want to apply them. To me this is not particularly convenient, but at least it's a working method and since I want to list all the working methods, it should be listed here.

Relevant official documentation: Export or Import Default Application Associations


Previous research on the topic gave this article and tool, alas it's not open source like the above.

-2

I just search my hard drive for the file extension that I am interested in...say *.jpeg Then I right click on just one of the files and on the "General" tab look at "opens with" then click on "change". In the dialogue box if you don't see your program scroll all the way down and click on "More Apps". Now you can pick the app to open that file extension type. You will see that it changes all files to your app of choice! Easy Peasy. Hope you get it, Dave

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .