MoonPoint Support Logo


Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals

Advanced Search
Sun Mon Tue Wed Thu Fri Sat

Wed, Nov 04, 2015 9:21 pm

Determining what application will open a file from the command line

If you wish to know what application will open a particular file type on a Microsoft Windows system, you can obtain that information from the command line using the ftype command.

c:\>ftype /?
Displays or modifies file types used in file extension associations

FTYPE [fileType[=[openCommandString]]]

  fileType  Specifies the file type to examine or change
  openCommandString Specifies the open command to use when launching files
                    of this type.

Type FTYPE without parameters to display the current file types that
have open command strings defined.  FTYPE is invoked with just a file
type, it displays the current open command string for that file type.
Specify nothing for the open command string and the FTYPE command will
delete the open command string for the file type.  Within an open
command string %0 or %1 are substituted with the file name being
launched through the assocation.  %* gets all the parameters and %2
gets the 1st parameter, %3 the second, etc.  %~n gets all the remaining
parameters starting with the nth parameter, where n may be between 2 and 9,
inclusive.  For example:

    ASSOC .pl=PerlScript
    FTYPE PerlScript=perl.exe %1 %*

would allow you to invoke a Perl script as follows: 1 2 3

If you want to eliminate the need to type the extensions, then do the


and the script could be invoked as follows:

    script 1 2 3

If you open a command prompt window and type ftype with no options, you will see all the file associations for the system on which the command is run, i.e., which applications will open particular file formats. You can pipe the output of the command into the more command to page through the information using the space bar or redirect the output to a file with ftype > somefile.txt.

c:\>ftype | more
Access=C:\Program Files\Microsoft Office 15\Root\Office15\protocolhandler.exe "%
Access.ACCDAExtension.15=C:\Program Files\Microsoft Office 15\Root\Office15\MSAC
Access.ACCDCFile.15="C:\Program Files\Microsoft Office 15\Root\Office15\MSACCESS
Access.ACCDEFile.15="C:\Program Files\Microsoft Office 15\Root\Office15\MSACCESS
.EXE" /NOSTARTUP "%1" %2 %3 %4 %5 %6 %7 %8 %9
Access.ACCDRFile.15="C:\Program Files\Microsoft Office 15\Root\Office15\MSACCESS
.EXE" /RUNTIME "%1" %2 %3 %4 %5 %6 %7 %8 %9
Access.ACCDTFile.15="C:\Program Files\Microsoft Office 15\Root\Office15\MSACCESS
Access.ADEFile.15="C:\Program Files\Microsoft Office 15\Root\Office15\MSACCESS.E
XE" /NOSTARTUP "%1" %2 %3 %4 %5 %6 %7 %8 %9
Access.Application.15="C:\Program Files\Microsoft Office 15\Root\Office15\MSACCE
SS.EXE" /NOSTARTUP "%1" %2 %3 %4 %5 %6 %7 %8 %9
Access.BlankDatabaseTemplate.15="C:\Program Files\Microsoft Office 15\Root\Offic
Access.BlankProjectTemplate.15="C:\Program Files\Microsoft Office 15\Root\Office
Access.Extension.15=C:\Program Files\Microsoft Office 15\Root\Office15\MSACCESS.
Access.MDBFile="C:\Program Files\Microsoft Office 15\Root\Office15\MSACCESS.EXE"
 /NOSTARTUP "%1" %2 %3 %4 %5 %6 %7 %8 %9
-- More  --

You might think that you could just type ftype ext, where txt is a 3-letter extension, e.g., ftype docx, to determine what application will open a file with a .docx extension, but that won't work.

c:\>ftype docx
File type 'docx' not found or no open command associated with it.

c:\>ftype txt
File type 'txt' not found or no open command associated with it.

You will need to know that a .txt file is identified as a "textfile" and a .docx file, which is an Office Open XML file format, is identified as a "docxfile" for that method to work, but you can use just the 3-letter extension, if you pipe the output of the ftype command to the find command as shown below:

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

c:\>ftype | find "docx"
docxfile="%ProgramFiles%\Windows NT\Accessories\WORDPAD.EXE" "%1"

From the above output, I can see that the Windows Notepad application is the default program for opening text files, i.e., the program that will open any file with a .txt extension if I double-click on the file in the Windows Explorer. And I can see that the Windows Wordpad, aka Write, program will open .docx files by default.

[/os/windows/commands] permanent link

Once You Know, You Newegg AliExpress by

Shop Amazon Local - Subscribe to Deals in Your Neighborhood

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo