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
- What assoc does
- How to open Command Prompt
- Assoc does not work in PowerShell
- Syntax and parameters
- View an association
- Set an association
- Remove an association
- Pair it with ftype
- What the % symbols mean in ftype
- Example: run a script by its extension
- Use Settings to choose the app
- Set defaults by app instead
- Common problems
- Sources
- More Windows guides
Quick answer
| Task | Command |
|---|---|
| List all associations | assoc |
| Check one extension | assoc .txt |
| Associate an extension with a file type | assoc .log=txtfile |
| Remove an association | assoc .bak= |
| Save the list to a file | assoc>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
- Select Start and type cmd.
- For read-only checks, open Command Prompt normally.
- 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>]]].
| Part | Meaning |
|---|---|
.ext | The file name extension, such as .txt |
filetype | The file type to link to that extension |
/? | Shows help at the command prompt |
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.
| Command | What it does |
|---|---|
ftype | Lists file types that have open command strings defined |
ftype txtfile | Shows 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.
| Variable | Replaced with |
|---|---|
%0 or %1 | The file name being launched through the association |
%* | All of the parameters |
%2, %3, and so on | The first parameter, the second parameter, and so on |
%~n | All 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.
- Run
assoc .pl=PerlScriptto link the extension to a file type named PerlScript. - Run
ftype PerlScript=perl.exe %1 %*to tell Windows which program opens that type. - 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.
- Open Settings and go to Apps, then Default apps.
- Type the extension, such as .txt, in the search bar.
- Select the matching result.
- 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.
- Open Settings and go to Apps, then Default apps.
- Select an app to see the file types and link types it can open.
- Select the file or link type you want to change.
- 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
| Problem | What to check |
|---|---|
| Access is denied when changing an association | Reopen Command Prompt with Run as administrator |
| Command is not recognized in PowerShell | Use cmd /c assoc or open Command Prompt |
| Syntax error with angle brackets | Remove the < and > characters from your command |
| Removal seems to do nothing | Run 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.
More Windows guides
- How To Uninstall ESET From Windows Step By Step (2026)
- How To Uninstall Kaspersky Completely From Windows (2026)
- Local Security Authority Protection Is Off In Windows 11 (2026)
- How To Use Ping And Tracert In Windows 11 (2026)
- How To Change UAC Settings In Windows 11 (2026)
- How To Rip A CD To Your PC In Windows 11 (2026)
See all: Windows 11 Guides