Change Default Apps and File Association via Command-line

Summary: This post explains how to change the default apps or file associations using the command-line in Windows 10. This can be accomplished by a command-line tool named SetUserFTA.

In Windows 10, setting per-user file associations for a logged-on user account has to be done only using Default Apps or the Open with dialog manually. If you try to change the user default registry entries using script or batch files, Windows 10 will reset the file association to Windows defaults; you’ll see the annoying An app default was reset notification.

Set Default Browser and File Associations via Command-line

Microsoft says applications must not write to the UserChoice registry key, which stores the user-default association settings. This is because the user must be in control, not the programs. Programs competing with each other and arbitrarily changing the user-specific associations will not be a good user experience. The UserChoice key is a protected location, and the ProgID value is validated with a hash.

Set Default Browser and File Associations via Command-line

When you use Default Apps or Open with to set associations, Windows 10 generates the hash for each file type association. The hash generated is based on many inputs like user account SID, ProgId, registry time, etc., and perhaps other parameters.

Users may sometimes need a shortcut method to set file associations for their account, without going through the Open with dialog or Default Apps every time. Some toggle switch or shortcut to change browser or file association defaults will be a great help.

Fortunately, we have the SetUserFTA tool to do that.

(Last tested with SetUserFTA version 1.7.1 on Windows 10 v21H1 on May 21, 2021. Works perfectly.)

Set Default Apps, Browser, or Associations via Command-line

To set the file association and default browser via command-line, use the SetUserFTA utility written by Christoph Kolbicz. Kolbicz has reverse-engineered the hashing algorithm effectively. This utility generates the hash automatically and sets the defaults for you.

Set Default Browser and File Associations via Command-line

To change the default browser using command-line, use this syntax:

SetUserFTA.exe extension progid

It also supports URL protocols (e.g., http, https, mailto, etc.)

Google Chrome

To set Chrome as the default browser, run these commands:

SetUserFTA  http ChromeHTML
SetUserFTA  https ChromeHTML
SetUserFTA  .htm ChromeHTML
SetUserFTA  .html ChromeHTML

Firefox

SetUserFTA  http FirefoxHTML
SetUserFTA  https FirefoxHTML
SetUserFTA  .htm FirefoxHTML
SetUserFTA  .html FirefoxHTML

Opera

SetUserFTA  http OperaStable
SetUserFTA  htts OperaStable
SetUserFTA  .htm OperaStable
SetUserFTA  .html OperaStable

Microsoft Edge (Chromium)

SetUserFTA http MSEdgeHTM
SetUserFTA https MSEdgeHTM
SetUserFTA microsoft-edge MSEdgeHTM
SetUserFTA .htm MSEdgeHTM
SetUserFTA .html MSEdgeHTM

Microsoft Edge (legacy)

SetUserFTA http AppXq0fevzme2pys62n3e0fbqa7peapykr8v
SetUserFTA https AppX90nv6nhay5n6a98fnetv7tpk64pp35es
SetUserFTA microsoft-edge AppX7rm9drdg8sk7vqndwj3sdjw11x96jc0y
SetUserFTA .htm AppX4hxtad77fbk3jkkeerkrm0ze94wjf3s9
SetUserFTA .html AppX4hxtad77fbk3jkkeerkrm0ze94wjf3s9

RELATED: See article How to Remove File Type Associations Using the Registry Editor for more information on File extension → ProgID mapping.



Default Image Viewer

To set Windows Photo Viewer as the default handler for .png and .jpg files, run:

SetUserFTA  .jpg  PhotoViewer.FileAssoc.Jpeg
SetUserFTA  .png  PhotoViewer.FileAssoc.Png

Note that you’ll have applied the Windows Photo Viewer registry edit as in the article Restore Missing Windows Photo Viewer in Windows 10 for the above commands to work. Without the necessary ProgId registration, your files will show up as an unknown file type.

To revert to Microsoft Photos as the default, use this command-line:

SetUserFTA .jpg AppX43hnxtbyyps62jhe9sqpdzxn1790zetc
SetUserFTA .png AppX43hnxtbyyps62jhe9sqpdzxn1790zetc

ProgID vs “Applications\program.exe”

If an application doesn’t define a file class or Progid, you can mention the program’s exe as well, like Applications\program.exe type as well. This works if the program is registered under HKCR\Applications registry key.

For example, to set Notepad++ as the default editor for .txt files, run:

SetUserFTA  .txt applications\notepad++.exe

To revert to default (notepad.exe), use:

SetUserFTA  .txt txtfile
or
SetUserFTA  .txt applications\notepad.exe

You may create desktop shortcuts for the required commands to switch defaults quickly in a single click!

View current user defaults for all file types

To get the user defaults for all file types and URL protocols, run the command:

SetUserFTA  get

Set Default Browser and File Associations via Command-line

SetUserFTA makes the job of setting file associations easy! There is a similar utility from Danysys.com, which I’ve not tested yet. If you want to check it out, visit Set File Type Association Default Application Command Line Windows 10 UserChoice Hash Internal Method.


One small request: If you liked this post, please share this?

One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
  • Pin it!
  • Share it to your favorite blog + Facebook, Reddit
  • Tweet it!
So thank you so much for your support. It won't take more than 10 seconds of your time. The share buttons are right below. :)

Ramesh Srinivasan is passionate about Microsoft technologies and he has been a consecutive ten-time recipient of the Microsoft Most Valuable Professional award in the Windows Shell/Desktop Experience category, from 2003 to 2012. He loves to troubleshoot and write about Windows. Ramesh founded Winhelponline.com in 2005.

20 thoughts on “Change Default Apps and File Association via Command-line”

  1. I’m just a user, not a geek techie! All this crap is meaningless to almost all of us. I’ll have
    to hire some body in order to be able to use a $1200 computer!

    Reply
  2. The program doesn’t appear to work, or the instructions don’t cover the most common cases. For example, how do I assign .jpg files to be opened by “C:\Program Files (x86)\IrfanView\i_view32.exe”?

    None of the following work, but none of them display any error message!
    setuserfta jpg “C:\Program Files (x86)\IrfanView\i_view32.exe”
    setuserfta .jpg “C:\Program Files (x86)\IrfanView\i_view32.exe”
    setuserfta .jpg i_view32.exe
    setuserfta .jpg application\i_view32.exe

    The following gives an error message:
    setuserfta .jpg application\”C:\Program Files (x86)\IrfanView\i_view32.exe”

    Reply
    • @cdg: Try:
      SetUserFTA.exe .jpg applications\i_view32.exe
      SetUserFTA.exe .jpg applications\mspaint.exe

      It’s “Applications” (not “Application”)

    • Hello:

      IrfanView is amongst the *friendliest* apps ever made! It provides a very simple and selectable method for setting all associations very easily and quickly. I have never had any problems with it, as long as it has been in existence and that is UNIQUE!

      https://www.irfanview.com/faq.htm

  3. I’ve ben attempting to work with Microsoft Tech Support under my paid support subscription and so far no one at the Tier 1 or 2 level acknowledges that the chose default application Graphical User Interface (GUI) and Open with functionality is flawed. The above article’s mention that MS protects the file extension associations with a hash is enlightening. I suppose this is block malicious code from making changes…? I have to laugh that .pub files which are generated my Microsoft Publisher, and .msg files are not automatically recognized by the OS and associated with those applications. What’s more when I try to associate them the OS doesn’t present those applications as choices.

    Reply
  4. Think this is getting into AntiTrust areas with MS forcing only its view of valid apps being allowed to be associated.
    Back to the days of bottling up IE to Windows and Governments bringing MS into court.

    Reply
  5. Unfortunately in most enterprise environments (where this is most useful), we are not able to download 3rd party unapproved apps.

    Reply
  6. Hey thanks for this article its great

    One issue though: I setup 3 batch files to switch between Chrome, Edge and Firefox.
    The first 2 work perfectly using the instructions as above.
    i.e. if I click on a link in an email it opens Chrome or Edge immediately

    But after running the Firefox batch file, if I click on the link in the email, it pops up a “How do you want to open this” dialog, with all the browsers listed.

    What am I missing?

    The bat file has this in it ( as per above)
    SetuserFTA http FirefoxHTML
    SetuserFTA https FirefoxHTML
    SetuserFTA .htm FirefoxHTML
    SetuserFTA .html FirefoxHTML

    Im running Firefox version 75.0 (64 bit)

    Thanks !

    Reply
  7. I can’t seem to get the program to work at all: After downloading it I set the command prompt as instructed (SetUserFTA get) and it returned the following message: “SetUserFTA” is not recognized as an internal or external command, operable program or batch file.

    Reply
  8. doesn’t work 27.8.22 21H2. tried to change mp4/mkv file associations to vlc and it either gives the usual “choose an app” without the checkmark to keep it that way or rollsback to the stupid ass photos. f** ms man.

    Reply
  9. Can this command apply the default to “all users” instead of “current user”?
    I can change the default for current user, but after I create another user, the previous default shown up again.

    Reply

Leave a Reply to OE Cancel reply