How To Set File App Association From Command Prompt On Windows 10
Windows 10 allows you to set any app of your choice as the default app to open a certain type of file. In some cases, e.g., with your browser, it will relentlessly try and push Edge as a superior option but with other file types and apps you don’t run into much resistance. Of course, app defaults often reset and sometimes they fail to set altogether. If that’s the case, you can always set a file app association from Command Prompt.
SPOILER ALERT: Scroll down and watch the video tutorial at the end of this article.
File App Association
In order to set a file app association from the Command Prompt, you need administrative rights. The first thing you need to do is find the file extension for the file that you want to set a default app for. This is easy enough; open File Explorer to the location with the file in it.
Right-click the file and select Properties from the context menu. On the General tab, you will see a ‘Type of File’ section that tells you what the file’s extension is.
Open Command Prompt with administrative rights and run the following command in it.
Syntax
assoc .fileextension
Example
assoc .html
This command will return the file type that the file is. This result is what you need to execute the command to set a file app association. In the screenshot below, the file type that the command has returned is “htmlfile”.
Next, find the absolute path to the EXE of the app you want to associate with the file type. Run the following command.
Syntax
ftype File Type="absolute-path-to-application" "%1"
Example
ftype htmlfile="C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "%1"
If the file app association is set successfully, Command Prompt will return the following.
File Type="absolute-path-to-application" "%1"
From this point forward, Windows 10 will use the set app to open the type of file you associated with it. This method doesn’t guarantee that the file association cannot be reset, or that no other apps can change it.
An error on Windows 10 may cause a file app association to reset. Likewise, if you install a new app that can also open the same file type, and set it as the default app for all such files, the file app association that you set will break.
If you’re interested in doing this for your browser so that Cortana doesn’t send web searches to Edge, this method isn’t going to work. You need an app called EdgeDeflector to redirect requests sent from Edge to Chrome or Firefox. If you use a different browser, give Search Deflector a try.
Thanks so much, this is really helpful!
Thank you so much for this EXTRMELY helpful post. As somebody new to the command line, I have been intimidate in the past by doing these sorts of things, and it is often hard to know if they have succeeded. Your instructions are clear and it worked perfectly for me to change the default .csv program to the DataCurator App. Thank you again – this made my day!
How to do with runas? This doesn’t seem to work:
ftype txtfile=”runas.exe /user:DESKTOP-K69RNHB\Boomy /env /savecred D:\Downloads\metapad36\metapad.exe” “%1”