Set File Type Association Default Application Command Line Windows 10 UserChoice Hash Internal Method

📢 SFTA.exe Latest Update 2020-09-14

Tested in: Windows 8, Windows 8.1, Windows 10 Version 1511, Windows 10 Version 1709, Windows 10 Version 1803, Windows 10 Version 1809, Windows 10 Version 1903, Windows 10 Version 1909

Recently one of my clients has asked me to change the default program associated with the extension  . pdf  to Acrobat Reader DC on Windows 10, all in an automated way. The first thing that comes to mind is to change it through the registry by editing the registry key UserChoice.

UserChoice Registry Key – Hash – ProgId

Hash entry that is generated automatically by Windows to validate the integrity of file type association.
ProgId entry is the Registered Application Id that handle the file type.

The main problem is that in recent versions of Windows 8/10 This key is protected by a hash associated with the file type, and succeeding in editing it without generating the valid hash the association is automatically restored to the default application.

Doing a quick search on Google I found some ways to do it, using GPO(Group Policy Object) or importing a .xml association file with DISM.exe, but they were a little extensive processes, after a deeper search and taking into account that my client needed a quick fix I found this little command line tool SetUserFTA.exe created by Christoph Kolbicz which complied with what was required and I opted to use momentarily, however I was intrigued to be able to include this method directly in an application developed in another language such as C++, AutoIt, Pascal or PowerShell.

After a couple of days fighting against Windows and doing some Google research, I manage to find the method that uses Windows internally and develop a code to implement in the application of my client.

I developed a small command line tool in PureBasic to perform this task over Windows 8/10 which is very simple to use.

SFTA Command Line Tool

Sample Usage:

Set Acrobat Reader DC as Default .pdf reader:

SFTA.exe AcroExch.Document.DC .pdf

Set Sumatra PDF as Default .pdf reader:

SFTA.exe Applications\SumatraPDF.exe .pdf

Set Google Chrome as Default for http Protocol :

SFTA.exe ChromeHTML http

I hope this tool will be useful.

SFTA Changelog


All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.


1.3.1 – 2020-09-14


  • Hash Algorithm Raw PureBasic Code

1.3.0 – 2020-04-24


  • Add Protocol Support
  • Add Icon Support for File Type

1.2.1 – 2019-12-13


  • Add –list Show All Application Program Id


  • Fix –get command

1.2.0 – 2019-12-12


  • Add Hash Algorithm Method to handle the latest Versions of Windows 10

1.1.0 – 2019-08-07


  • Add –reg Register Application Program Id
  • Add –unreg Unregister Application Program Id
  • Add –debug Display Debug Information
  • Add Windows 10_1115 Support – Thanks to Mehdi

1.0.0 – 2019-01-22

First Release

45 thoughts on “Set File Type Association Default Application Command Line Windows 10 UserChoice Hash Internal Method

  • I tried the command line:
    sfta.exe -h
    this works fine.

    However, the next command line:
    sfta.exe -g “.txt” returns : “Error. Unable To Query Associated Application” when my .txt files are associated with notepad.exe.

  • I tried to change association for .htm but the only thing it did was to break the existing association. Next time when I double-clicked a .htm file Windows asked me what program I wanted to open the file with.

    Command I used: sfta –reg “C:\Program Files (x86)\Google\Chrome\Application\Chrome.exe” “.htm”
    OS: Windows 10

    Next I checked the code from github. That does not seem to include calculation of the Hash.

    Dont know what I am doing wrong.


    • Hello @Asad, Seems to be you have already installed Chrome so It already has Program ID registered. You just need to do this.

      SFTA.exe "ChromeHTML" ".htm"

      About “calculation of the Hash” It’s is done by the interface IApplicationAssociationRegistrationInternal internally.


  • Looks like the tool is not working.

    PS C:\Windows\System32\WindowsPowerShell\v1.0> sfta -d “FoxitReader.Document” “.pdf”
    [2019.10.17 16:28:15] OSVersion = 110
    Windows Version: Windows 10
    Windows ReleaseId: 1903
    Windows Build: 18362
    Windows ProductName: Windows 10 Enterprise
    [2019.10.17 16:28:15] Is Windows 10
    [2019.10.17 16:28:15] FAIL AssociationRegistration Instance

  • Not working 🙁
    C:\Users\User\Desktop\SFTA-1.2.1>SFTA.exe -d “7-Zip.rar” “.rar”
    [2020.01.21 10:56:00] OSVersion = 110
    Windows Version: Windows 10
    Windows ReleaseId: 1909
    Windows Build: 18363
    Windows ProductName: Windows 10 Enterprise
    [2020.01.21 10:56:00] Is Windows 10
    [2020.01.21 10:56:00] FAIL AssociationRegistration Instance
    [2020.01.21 10:56:00] Experience String Found
    [2020.01.21 10:56:00] Hash: LPFBiCwvmtk=
    [2020.01.21 10:56:00] Write Reg UserChoice OK
    [2020.01.21 10:56:00] SetFileTypeAssociation Hash Method OK

    • Hello @Alexander, Did you try with other application? maybe a PDF for testing. Are you sure 7-Zip.rar is the correct Application ID for 7zip? Make sure to pass the debug parameter (-d) at the end.
      Seems to be 7-Zip does not register the Application ID by default. You would need to go to 7-Zip’s menu Options and add .rar type, it registers Application ID and this command will work SFTA.exe “7-Zip.rar” “.rar”. If you want to avoid manually change 7-zip options you can use SFTA’s -r command, It will register the Application ID and associate it automatically with this command SFTA.exe -r “C:\Program Files\7-Zip\7zFM.exe” “.rar”

      • The same 🙁

        C:\Users\User\Desktop\SFTA-1.2.1>SFTA.exe -r “C:\Program Files\7-Zip\7zFM.exe” “.rar” -d
        [2020.01.21 17:12:07] OSVersion = 110
        Windows Version: Windows 10
        Windows ReleaseId: 1909
        Windows Build: 18363
        Windows ProductName: Windows 10 Enterprise
        [2020.01.21 17:12:07] Is Admin
        [2020.01.21 17:12:07] Application Program Id = “SFTA.7zFM.Application”
        [2020.01.21 17:12:07] ASSOC Return = 0
        [2020.01.21 17:12:07] FTYPE Return = 0
        [2020.01.21 17:12:07] Is Windows 10
        [2020.01.21 17:12:07] FAIL AssociationRegistration Instance
        [2020.01.21 17:12:07] Experience String Found
        [2020.01.21 17:12:07] Hash: z7+k4YXuUig=
        [2020.01.21 17:12:07] Write Reg UserChoice OK
        [2020.01.21 17:12:07] SetFileTypeAssociation Hash Method OK

      • And this is for Adobe Acrobat XI Pro 11.0.23 and pdf extension. It change the icon, but when I click the pdf file – annoying dialog with program selection popups (Acrobat is selected already in that dialog, and if I tell to use that app everytime – everything is OK).

        C:\Users\User\Desktop\SFTA-1.2.1>SFTA.exe “Acrobat.Document.11” “.rar” -d
        [2020.01.21 17:15:25] OSVersion = 110
        Windows Version: Windows 10
        Windows ReleaseId: 1909
        Windows Build: 18363
        Windows ProductName: Windows 10 Enterprise
        [2020.01.21 17:15:25] Is Windows 10
        [2020.01.21 17:15:25] FAIL AssociationRegistration Instance
        [2020.01.21 17:15:25] Experience String Found
        [2020.01.21 17:15:25] Hash: TM8D+ZHHTCo=
        [2020.01.21 17:15:25] Write Reg UserChoice OK
        [2020.01.21 17:15:25] SetFileTypeAssociation Hash Method OK

        • Try this command and post console output.

          SFTA.exe -r "C:\Program Files\7-Zip\7zFM.exe" ".rar" -d

          I’ll do some tests to check what’s going wrong because It’s working fine in my side.


          • Seems have found the problem – by bad. Need to use:




            and the popup dialog dissapears.

  • Hi Danny, thanks for this tool. It seems like it doesn’t work for the default browser setting (which modifies the protocols http and https, additionally to the .htm and .html file extensions.
    When you use SFTA.exe MSEdgeHTM .https the modification needs to be written here: HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice

    Same with .http. Is there any chance you can add the different registry paths for these two protocols?

  • Hi Dany,
    Thank you so much for this tool! I had never seen PureBasic project in my life before I saw this so I guess I got to geek out a little bit as I was going through this. I still suck at reading it though. I love that this is open source, but do I understand correctly that all of this is readable code except for the GenerateHash function which is hidden away in the hash.a (compiled in C?) file?
    My apologies if this is a silly basic coding question I should know the answer to.. but any pointer you could provide would be greatly appreciated.

    • Hi, I got the hash using a debugger so It was a very messed C routine that I compiled to static library. I’m planning to convert the hash routine to raw PureBasic code, but haven’t had a chance to do it yet.


      • Hi Dany,
        Thank you for the quick reply! That would be awesome and would really help so I’ll look forward to that.

  • Hi, Danny. Thanks for your great work! It works like a charm. But I want to ask a further question. I’m trying to associate FTP protocol with a custom program. And in this custom program I intend to forward the FTP url (a file on FTP) to different applications according to the extension of the file (on FTP) and the system default applications settings. I can get all the system associated ProgIds with the help of your SFTA.exe. But how can I invoke the application (with a proper format) if I know the ProgId? Wonder if you have any suggestions on achieving this? Thanks!

    • Hello Zezheng. I’m not sure If I understand what you’re trying to do. But Basically You would associate the FTP protocol with your Custom App like this:

      SFTA.exe "YourAppID" "ftp"

      If You don’t have your App registered:

      SFTA.exe --reg "C:\MyCustomApp.exe" "ftp"

      After that You will be able to pass the FTP url as parameter to your custom application like this using a cmd prompt:

      start ftp:\\YourFTPFile.txt"

      That will invoke your CustomApp with the url as parameter.


  • Hola Amigo muchisimas gracias funciona excelente, pero tengo una duda, hay manera de que al ejecutar SFTA.exe AcroExch.Document.DC .pdf funcione para todos los usuarios en el equipo? ya que actualmente solo funciona con el usuario en donde se ejecute, y al iniciar sesion en otro usuario no está acrobat predeterminado.
    De antemano agradezco tu respuesta.
    Saludos desde Guatemala

      • Muchisimas Gracias Dany, me serviría mucho para cambiar opciones remotas pormedio de psexec y que se apliquen a todos los usuarios de una sola computadora.
        Gracias nuevamente

  • Hi Dany, thanks a lot for your work. It is highly appreciated that you share your source code!

    Do you know if there are any plans to make a new Powershell version for 1809 and higher ?

  • Hello
    I’m really looking forward to the powershell version.
    Although if I could get the hash algorithm privately, I could already use it without the full script and thank you very much for that.

  • Thanks, this works wonderfully. I’m confused as to why they make it so hard for us to set an association for specific users. Is this some sort of protection that MS implemented, and will they eventually break your tool?

    • Hello! I’m pretty sure Microsoft added it for security reasons. I’m not sure if they will make changes that break my tool anyway. I will try to keep it updated when it happens. Regards

Leave a Reply

Your email address will not be published. Required fields are marked *