assoc / ftype - File Associations

Maintained on

When you double-click a .txt file in File Explorer and Notepad opens, that is because the extension is associated with an app.

assoc and ftype are commands for viewing and changing these associations from Command Prompt.

The Difference Between assoc and ftype

A Windows file association works in two steps.

  1. Extension → file type (handled by assoc)
  2. File type → command to run (handled by ftype)
CommandWhat it handlesExample
assocExtension to file type.txt → txtfile
ftypeFile type to the command that opens ittxtfile → command that runs Notepad

When you open a .txt file, Windows uses the assoc information to find the type “txtfile”, then uses the ftype information to decide which program to launch.

Internal commands of cmd.exe

assoc and ftype are built into cmd.exe. PowerShell has no cmdlets with these names, so from PowerShell run them with cmd /c, as in cmd /c assoc .txt.

How to Use assoc

Viewing an Association

Syntax
assoc [.extension[=[filetype]]]

If you specify an extension, the file type for that extension is displayed.

Check_the_association_for_.txt
assoc .txt
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>assoc .txt
.txt=txtfile
C:\users\user>

If you run it with no arguments, all registered associations are listed. The list is long, so combining it with findstr or more is handy.

Filter_by_extension
assoc | findstr /i "\.htm"
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>assoc | findstr /i "\.htm"
.htm=htmlfile
.html=htmlfile
C:\users\user>
おすすめ書籍※ 広告を含む場合があります
中小企業経営者のためのRPA入門 RPA導入を成功させる方法

中小企業経営者のためのRPA入門 RPA導入を成功させる方法

60分でわかる! AIエージェント 超入門

60分でわかる! AIエージェント 超入門

コマンドラインの黒い画面が怖いんです。

コマンドラインの黒い画面が怖いんです。

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門

For how to use pipes, see

.

Output varies by environment

File type names depend on the installed apps. For example, .html may be named htmlfile, ChromeHTML, MSEdgeHTM, and so on, depending on the browser.

Changing or Deleting an Association

Specify a file type on the right side of = to set the mapping for an extension.

Give_.log_the_same_type_as_txtfile
assoc .log=txtfile

Leave the right side of = empty to delete the association for that extension.

Delete_the_association_for_.log
assoc .log=
Administrator rights are required

Changes to associations are written to HKEY_LOCAL_MACHINE\Software\Classes in the registry. In a regular Command Prompt you will see “Access is denied”, so run it as administrator by following

.

How to Use ftype

Viewing the Command for a File Type

Syntax
ftype [filetype[=[command string]]]

If you specify a file type, the command that is run to open that kind of file is displayed.

Check_how_txtfile_is_opened
ftype txtfile
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>ftype txtfile
txtfile=%SystemRoot%\system32\NOTEPAD.EXE %1
C:\users\user>

%1 is replaced with the path of the file being opened. Depending on the environment, %L (the file path) or %* (the remaining arguments) may also be used. Running ftype with no arguments lists all file types and their commands.

Changing the Command

Open_txtfile_with_a_different_editor
ftype txtfile="C:\Program Files\MyEditor\editor.exe" "%1"

If the path contains spaces, enclose the executable’s path in ". It is also standard to write "%1" in quotes so that file names containing spaces work.

Use %% in batch files

When you write %1 inside a batch file, double the percent sign as %%1. Otherwise it is replaced by the batch file’s own first argument. See

for details.

Like assoc, ftype requires administrator rights to make changes.

Practical Examples

Registering a New Extension and Opening It with a Specific App

This example creates a new .myd extension and opens it with your own app. Run it as administrator.

register-myd.bat
@echo off
rem Register .myd as the MyDataFile type
assoc .myd=MyDataFile

rem Set how MyDataFile is opened
ftype MyDataFile="C:\Tools\mydata.exe" "%%1"

To remove it later, run assoc .myd= and ftype MyDataFile=.

Finding Out Which App Handles an Extension

Look up the type with assoc, then look up the command with ftype.

Find_the_command_that_opens_.py
assoc .py
ftype Python.File

On the second line, specify the file type shown by the first line (Python.File here).

Searching the ftype List for a Specific App

Find_types_associated_with_Notepad
ftype | findstr /i "notepad"

When Your Changes Don’t Take Effect

Even after you change assoc or ftype, the app that opens on double-click may not change.

Since Windows Vista, the app a user picks with “Always use this app” is stored per user in the registry (HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.extension\UserChoice). This setting takes priority over assoc and ftype.

  • assoc / ftype rewrite the machine-wide default association (ProgID). If the user’s chosen default app (UserChoice) points to a different ProgID, it takes priority and your change has no effect.
  • To change the default app, use “Default apps” under “Apps” in Windows Settings.
  • What assoc / ftype display is the content of HKEY_CLASSES_ROOT; the default app the user chose in Settings (UserChoice) is not reflected.
Check with the start command

You can check which app actually opens a file with start "" filename. start opens files according to the association. See

for details.

Summary

  • assoc handles “extension → file type”, and ftype handles “file type → command to open it”
  • Run with no arguments for a list; use assoc .extension or ftype type to check one entry
  • Use = to set, and leave the right side of = empty to delete (assoc .log= / ftype type=)
  • Changes require administrator rights, and %1 in a batch file must be written %%1
  • The user’s chosen default app takes priority, so if changes don’t apply, check the “Default apps” settings

Practice Questions

Practice Problem

Which statement about assoc and ftype is correct?

Choose one answer.

  1. assoc handles the file type to command mapping, and ftype handles the extension to file type mapping
  2. assoc handles the extension to file type mapping, and ftype handles the file type to command mapping
  3. Both link an extension directly to a command

Practice Problem

Which command deletes the association for .log?

Choose one answer.

  1. assoc .log
  2. assoc .log=txtfile
  3. assoc .log=
#Command Prompt #Batch File #Command Line #Command #assoc #ftype #File Association