Change Default Apps, Browser or File Association via Command-line in Windows 10

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, and 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 is not going to be 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.

Default Browser & File Association via Command-line in Windows 10

Users may sometimes need a shortcut method to set file associations for their user 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 for users.

Luckily, we have the SetuserFTA tool to do that. 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

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 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.

Note: 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

About the author

Ramesh Srinivasan founded Winhelponline.com back in 2005. He is passionate about Microsoft technologies and he has been a Microsoft Most Valuable Professional (MVP) for 10 consecutive years from 2003 to 2012.

1 thought on “Change Default Apps, Browser or File Association via Command-line in Windows 10”

  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!

Leave a Comment