Type Associations in Windows

I’ve just found out about two convenient shell commands that can be used to check out and change/remove file associations in Windows. The first one is ftype, that allows you to define aliases for executable files to be invoked. The other one is assoc, whereby you can associate file name extensions to the aforementioned aliases.

You can use ftype to view a list of file types like this

or – if you’re interested in only one particular type (eg. rbFile)

In order to remove an existing file type, just add an equals sign to the name of the type, like this

If you want to add a new file type, instead, just specify the path to the executable after the equals sign, for example

Note the special syntax involving the percent sign: %0 or %1 stand for the file name in question (the one being opened), whereas %n (with n from 2 to 9) represents the parameters following the file name; you can also use %* (all parameters) or %~n (with n from 2 to 9) meaning all parameters after the nth.

In a similar fashion, assoc allows to associate a file extension to a specific file type. You can use it to view (no parameter or just the extension you’re interested it), remove (extension followed by equals sign) or add (extension, equals and file type) associations in the system. Note that the extensions should be specified with the dot prefix, like in the examples.

So, in conclusion, here’s the syntax of these two useful DOS commands:

Leave a comment

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