Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

Assoc cmd command

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Assoc is command (internal) found inside Windows Command Processor Command Prompt, that allows for file extension to file type association. A file extension is generally last few characters in File Name after period (“.”). Though it is not mandatory for file to have an extension at all (in case of extension-less files).

Extension to file type association is enforced predominantly by Windows OS. Other Operating Systems such as Linux and macOS does support such association but don’t enforce them to levels of Windows. Linux Kernel rather utilizes Magic Numbers for recognition of file types. In this article, we will take look at assoc command found in cmd, and would look at uses of it.

Description of Command :

ASSOC [.ext[=[fileType]]]

 .ext      Specifies file extension to associate file type with
 fileType  Specifies file type to associate with file extension

Type ASSOC without parameters to display current file associations. If ASSOC is invoked with just file extension, it displays current file association for that file extension. Specify nothing for file type and command will delete association for file extension.

Note –
The above text could be obtained by executing assoc /? Command in command line

Using the Command :
Displaying the list of every extension to file type association. To display list, execute following command in cmd.

Assoc :
After the execution, an output appears as such.


Displaying file type association of single file extension :

To display association, run following command.

assoc ext 

where ext is file extension we are wanting to get information about.

Example :
To get association information about the .jpg file extension

assoc .jpg 

Output :


Note –
There should always be period preceding the extension.

Creating file type association :
Requires cmd to run with elevated privileges (administrator mode). For creating file type associated with an extension, following command is to be used.

assoc extension=filetype 

Here, an extension is file extension that we want to associate, and file type is type with which we want to associate that extension with. The extension should always be preceded with period/Full stop, and there should always be an equal ( = ) sign between extension and file type.

Example :
The command for associating the .jkl extension with pngfile filetype.

assoc .jkl=pngfile 
  • It should be noted that the association of any extension should be done with known file type (ones known to operating systems). Otherwise, OS may become clueless with which application to assign for that particular file type.
  • That is due to the fact that Just like extensions are associated with file types, file types are further associated with an application. Therefore, if the user chooses new filetype, then it would not have an application associated with it (this could be dealt with by associating an application to the file type using ftype).
My Personal Notes arrow_drop_up
Last Updated : 15 Sep, 2020
Like Article
Save Article
Similar Reads