Freigeben über


Making file type associations enterprise ready

You may have noticed already that file type association has changed fundamentally in Windows 10. It is no longer possible for Administrators to set the default application for a certain file type dynamically. The only remaining option is, to create an XML file containing the desired FTA’s and import it using DISM (only valid for new users) or apply it using GPO (valid for all users on a PC). Here’s a good technical explanation about how FTA works in Windows 10.

The solution I’m providing here adds a bit of dynamics to the file type association topic (FTA). It is still a workaround but it lets you modify file type associations by using a Powershell script. Make sure to configure your environment as mentioned below.

Prepare your environment

  • Create a default file type association XML, which works with your standard client (click here to see how to export FTA's). Make sure that your FTA XML file only contains extensions you want to modify. Simply remove the lines with extensions you want to leave untouched. You can also deploy an empty XML if you don’t want to assign any file types yet. An empty file would look like this:
    <?xml version="1.0" encoding="UTF-8"?> <DefaultAssociations> </DefaultAssociations>
  • Use your preferred deployment method to push the file to your clients or add it to your master image. Select a local folder, which is readable but not changeable for users. The C:\ProgramData\YourCompany folder would be a good place. You can refer to it in the GPO with the %ProgramData% variable.
  • Create a GPO which affects all Windows 10 clients and change the setting as shown in the picture. Point the path to the location, where you copied your XML file.

On a client, which is in scope of the GPO, do a GPUPDATE and log off/on to apply the changes. The settings of you FTA XML should now take effect.

You can check the registry for verification. If you changed, for example, the assignment for .AVI files in your config file, you should find a registry value HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.avi\UserChoice\ProgId. The data of this value should be the same as the ProgId specified in your XML. And of course .AVI files should open with the application you assigned it to. If this is not the case, check the event log Microsoft-Windows-Shell-Core/AppDefaults for errors.

Add script to application deployments

Let’s assume you deploy an application to a set of clients, which handles a file type you already assigned to an application in your XML. You want to change the default app for this file type. To accomplish this, simply run the Powershell script attached to this article after the installation of the new application. You can also make this part of your app deployment.

Modify-AppAssocXml.ps1 -Path "C:\ProgramData\YourCompany\AppAssoc.xml" -Extension ".avi" -ProgId "VLC.avi" -AppName "VLC Media Player"

This modifies the local application association XML file. It changes .AVI to the new AppId or adds a new line, if AVI is not yet assigned. To use this script, you should understand the values the command accepts.

Path is straightforward. It’s the path to your local FTA config file.
Extension is the file type(s) you want to modify or set. You can either specify a single extension or multiple extensions, separated by comma (i.e. ".avi,.mp4,.mpeg")
ProgID is the path to the open handler in the registry, relative from HKEY_CLASSES_ROOT to the key name before Shell\Open\Command. An Example: The open handler for “notepad.exe” can be found in HKEY_CLASSES_ROOT\Applications\notepad.exe\shell\open\command. The ProgID for Notepad would be Applications\notepad.exe.
AppName is the file description property of the corresponding EXE file. However, this value does not affect the file type association but it must be set.

Unfortunately, it requires GPO foreground processing for the settings to take effect. This means that users need to log off/on after the FTA XML has changed.

Comments

  • Anonymous
    March 14, 2018
    Does this work if the application is already deployed, but another one is handling the association? E.g the user has associated PDF with Adobe Reader, and Chrome is installed. You want to force the association of PDF with Chrome.
    • Anonymous
      March 14, 2018
      Yes, this works for your scenario. Remember, that the user must logoff/logon after the modification of the XML is done.
  • Anonymous
    March 16, 2018
    Good one!