Determining the application that will open a file from the command line

If there is no program set as the default application for opening a file type, when you right click on a file of that file type and choose Properties, you will see "Pick an app" next to "Opens with".

.lit file properties

If you wish to identify all of the extensions known by the system, you can use the assoc command. If you type the command at a command prompt with no parameters, you will get a long list. You can redirect the output to a file with assoc > list.txt or page through it by piping the output of the command to the more command with assoc | more.

C:\>assoc | more
.386=vxdfile
.3g2=QuickTime.3g2
.3ga=VLC.3ga
.3gp=QuickTime.3gp
.3gp2=QuickTime.3gp2
.3GPP=QuickTime.3gpp
.669=VLC.669
.7z=WinRAR
.8bc=Photoshop.PlugIn
.8be=Photoshop.PlugIn
.8bf=Photoshop.PlugIn
.8bi=Photoshop.PlugIn
.8bp=Photoshop.PlugIn
.8bs=Photoshop.PlugIn
.8bx=Photoshop.PlugIn
.8by=Photoshop.PlugIn
.8li=Photoshop.PlugIn
.a52=VLC.a52
.aac=QuickTime.aac
.abr=Photoshop.BrushesFile
.ac3=QuickTime.ac3
.accda=Access.ACCDAExtension.15
.accdb=Access.Application.15
.accdc=Access.ACCDCFile.15
-- More  --

The syntax for the command is shown below.

C:\>assoc /?
Displays or modifies file extension associations

ASSOC [.ext[=[fileType]]]

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

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

C:\>

To see the association for a particular extension, type assoc .ext, where .ext is the extension you are interested in. If there is an application already associated with the extension, the type of file will be displayed or you will see a "File association not found for extension", if there currently is no application associated with the file extension.

C:\>assoc .txt
.txt=txtfile

C:\>assoc .pub
.pub=Publisher.Document.12

C:\>assoc .xls
.xls=Excel.Sheet.8

C:\>assoc .lit
File association not found for extension .lit

C:\>

There was no application configured currently to open "literature" .lit files on the system. That type of file is one used by Microsoft Reader.

From the description of the file type shown next to the extension, you can determine what application will open it using the ftype command. If you type just ftype at a command prompt, you will get a long list of file associations, so you can pipe the output of the ftype command into the find command to limit the associations displayed to just the one you are interested in as shown below.

C:\>ftype | find "Publisher.Document"
Publisher.Document.12="C:\Program Files (x86)\Microsoft Office 2007\Office12\MSPUB.EXE" %1
Publisher.Document.15="C:\Program Files\Microsoft Office 15\Root\Office15\MSPUB.EXE" /ou "%u" "%1"

C:\>ftype | find "txtfile"
txtfile=%SystemRoot%\system32\NOTEPAD.EXE %1

C:\>

You can also identify the application that is the default application for opening a file from a command prompt using a reg query command. E.g., if there is an application configured to open a particular type of file for the current user's account rather than for all users on the system, you can query the entries under HKEY_CURRENT_USER\SOFTWARE in the Windows registry. HKEY_CURRENT_USER can be abbreviated to HKCU. E.g., in the example below, I can see Calibre, a free and open-source program for reading and managing e-books, is the default application for opening Open eBook .opf files for the currently logged on user, but there is no HKCU entry for the .lit extension.

C:\>reg query HKCU\SOFTWARE\ /s /v .opf

HKEY_CURRENT_USER\SOFTWARE\calibre\Viewer64bit\Capabilities\FileAssociations
    .opf    REG_SZ    calibreViewer64bit.AssocFile.OPF

End of search: 1 match(es) found.

C:\>reg query HKCU\SOFTWARE\ /s /v .lit

End of search: 0 match(es) found.

C:\>

There is also no HKCU entry for .xls; the registry entry for that filetype, instead, can be found under HKEY_LOCAL_MACHINE (HKLM), which indicates that the entries in the registry are the default ones for all user accounts on the system. There is no HKLM entry for the .opf extension, which is under HKCU.

C:\>reg query HKCU\SOFTWARE\ /s /v .xls

End of search: 0 match(es) found.

C:\>reg query HKLM\SOFTWARE\ /s /v .xls

HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Spreadsheet\Microsoft Excel\Capabilities\Fil
eAssociations
    .xls    REG_SZ    Excel.Sheet.8

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\15.0\ClickToRun\AppVMachineRegistry
Store\Integration\Ownership\Software\Clients\Spreadsheet\Microsoft Excel\Capabil
ities\FileAssociations
    .xls    REG_SZ    {9AC08E99-230B-47E8-9721-4577B7F124EA},SPAD

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\15.0\ClickToRun\REGISTRY\MACHINE\So
ftware\Clients\Spreadsheet\Microsoft Excel\Capabilities\FileAssociations
    .xls    REG_SZ    Excel.Sheet.8

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap
    .xls    REG_SZ    document

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explore
r\KindMap
    .xls    REG_SZ    document

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Clients\Spreadsheet\Microsoft Excel\Capa
bilities\FileAssociations
    .xls    REG_SZ    Excel.Sheet.8

End of search: 6 match(es) found.

C:\>reg query HKLM\SOFTWARE\ /s /v .opf

End of search: 0 match(es) found.

C:\>

Since Calibre can read .lit files, I can associate it with .lit files to allow the user to just-double click on a .lit file to open it in Calibre. Prior to making that change, the file association registry entries for Calibre for the user's account were as follows:

Udemy

Calibre file associations

I then configured the Windows 10 operating system to use Calibre as the default application for opening .lit files. I could then double-click on a .lit file and have it open in Calibre, though the assoc command didn't show any reference for .lit files, but it also didn't show any for .opf, though Calibre could also open those even prior to this change. Nor did the ftype command show any reference to Calibre.

C:\>assoc .opf
File association not found for extension .opf

C:\>assoc .lit
File association not found for extension .lit

C:\>assoc | find /i "calibre"

C:\>ftype /i | find /i "calibre"
File type '/i' not found or no open command associated with it.

C:\>

The association of Calibre with .lit files through the File Explorer didn't add an entry under the HKEY_CURRENT_USER\SOFTWARE\calibre\Viewer64bit\Capabilities\FileAssociations registry key.

References:

  1. Determining what application will open a file from the command line
    Date: November 4, 2015
    MoonPoint Support

 

Firstrade newegg.com

Justdeals Daily Electronics Deals1x1 px