|

How To Use The Assoc Command In Windows (2026)

The assoc command shows or changes which file type Windows links to a file name extension.

It runs in Command Prompt, and changing an association needs administrator rights.

This guide covers every form of the command that Microsoft documents, plus the related ftype command.

Table of Contents

Quick answer

TaskCommand
List all associationsassoc
Check one extensionassoc .txt
Associate an extension with a file typeassoc .log=txtfile
Remove an associationassoc .bak=
Save the list to a fileassoc>assoc.txt

What assoc does

Microsoft says assoc displays or modifies file name extension associations.

Run on its own, it prints a list of every current association.

The page applies to Windows 11 and Windows 10, plus current Windows Server releases.

How to open Command Prompt

  1. Select Start and type cmd.
  2. For read-only checks, open Command Prompt normally.
  3. For changes, right-click it and choose Run as administrator.

Microsoft says you need administrator privileges to change associations.

Our guide to opening an elevated Command Prompt covers other ways to get there.

Assoc does not work in PowerShell

Microsoft says assoc is only supported within cmd.exe and is not available from PowerShell.

If you are in PowerShell or Windows Terminal with a PowerShell tab, type cmd /c assoc .txt instead.

Microsoft lists this exact workaround on the assoc page.

Syntax and parameters

The syntax is assoc [<.[ext]>[=[<filetype>]]].

PartMeaning
.extThe file name extension, such as .txt
filetypeThe file type to link to that extension
/?Shows help at the command prompt
Do not type the angle brackets. Microsoft says cmd.exe treats them as redirection operators and returns an error, so type assoc .jar= and not assoc .jar=<filetype>.

View an association

Type assoc .txt to see the file type linked to .txt files.

Type assoc | more to read the full list one screen at a time.

Type assoc>assoc.txt to send the list to a text file instead of the screen.

That last form uses the redirection operator, which Microsoft documents for saving the output.

Set an association

Type assoc .log=txtfile to associate .log files with the text file type.

This is Microsoft’s own example, and it works in an administrator Command Prompt.

To associate files that have no extension, use just a dot, as in assoc .=txtfile.

Remove an association

Type the extension, an equals sign, and nothing else, as in assoc .bak=.

Microsoft says you do not need a trailing space after the equals sign.

Do not type placeholder text after the equals sign.

Run assoc .bak afterward to check the result.

Pair it with ftype

Assoc links an extension to a file type, and ftype defines the open command for that file type.

Microsoft says ftype is also supported only within cmd.exe, with cmd /c ftype as the workaround.

CommandWhat it does
ftypeLists file types that have open command strings defined
ftype txtfileShows the open command for the txtfile type
ftype example=Deletes the open command string for a type called example
ftype PerlScript=perl.exe %1 %*Microsoft’s example for running Perl scripts

Microsoft shows txtfile=%SystemRoot%\system32\NOTEPAD.EXE %1 as sample output for ftype txtfile.

Microsoft says ftype run without an assignment operator displays the current open command string for the file type you name.

Run with no parameters, it lists every file type that has an open command string defined.

Use that list to find the file type name that assoc shows for an extension, then check its open command.

What the % symbols mean in ftype

Microsoft documents how ftype replaces variables inside an open command string.

VariableReplaced with
%0 or %1The file name being launched through the association
%*All of the parameters
%2, %3, and so onThe first parameter, the second parameter, and so on
%~nAll remaining parameters starting with the nth parameter, where n is 2 to 9

That is why the Notepad example ends in %1, which passes the file you opened to the program.

Example: run a script by its extension

Microsoft’s ftype page combines both commands to make .pl files run with Perl.

  1. Run assoc .pl=PerlScript to link the extension to a file type named PerlScript.
  2. Run ftype PerlScript=perl.exe %1 %* to tell Windows which program opens that type.
  3. Run set PATHEXT=.pl;%PATHEXT% if you want to run a script without typing its .pl extension.

The same pattern works for other scripting tools once you swap in your own extension, file type name, and program.

Use Settings to choose the app

For choosing which app opens a file type, Microsoft’s documented route is Settings.

  1. Open Settings and go to Apps, then Default apps.
  2. Type the extension, such as .txt, in the search bar.
  3. Select the matching result.
  4. Choose the app that should open that file type.

The assoc page does not say how its changes interact with these Default apps choices, so use Settings when you simply want a different program.

Our guide to changing file associations in Windows 11 walks through it in more detail.

Set defaults by app instead

Microsoft documents a second route in Settings that starts from the app instead of the file type.

  1. Open Settings and go to Apps, then Default apps.
  2. Select an app to see the file types and link types it can open.
  3. Select the file or link type you want to change.
  4. Choose your preferred app.

You can also open that page directly with the shortcut ms-settings:defaultapps.

To make Microsoft Edge your default browser, select Edge under Set defaults for applications, then select Set default.

Common problems

ProblemWhat to check
Access is denied when changing an associationReopen Command Prompt with Run as administrator
Command is not recognized in PowerShellUse cmd /c assoc or open Command Prompt
Syntax error with angle bracketsRemove the < and > characters from your command
Removal seems to do nothingRun assoc .ext again to confirm the association is gone

Sources

The full reference is on the Microsoft Learn assoc page.

The related command is covered on the ftype page.

The Settings steps come from Change default apps in Windows.

Leave a Reply

Your email address will not be published. Required fields are marked *