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.
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.
After the execution, an output appears as such.
.001=WinRAR .386=vxdfile .3ds=Photoshop.3DSFileType.130 .3g2=WMP11.AssocFile.3G2 .3ga=VLC.3ga .3gp=WMP11.AssocFile.3GP .3gp2=WMP11.AssocFile.3G2 .3gpp=WMP11.AssocFile.3GP .669=VLC.669 .7z=WinRAR .8ba=Photoshop.PlugIn .8bc=Photoshop.PlugIn
Displaying file type association of single file extension :
To display association, run following command.
where ext is file extension we are wanting to get information about.
To get association information about the .jpg file extension
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.
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.
The command for associating the .jkl extension with pngfile filetype.
- 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).
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.