CMD Simulator
System Informationassoc

ASSOC Command Guide - Display and Modify File Extension Associations in Windows

Learn how to use the assoc command to display, set, or modify file extension associations in Windows Command Prompt. Includes syntax, examples, troubleshooting, and best practices.

Rojan Acharya··Updated Feb 5, 2026
Share

The assoc command is a Windows Command Prompt utility that displays or modifies file extension associations, which determine which program opens files with specific extensions. Use assoc .ext to view the file type associated with an extension, or assoc .ext=fileType to set or change associations for automated file handling and system configuration.

Whether you're troubleshooting file association issues, configuring default programs for file types, or managing system-wide file type mappings in enterprise environments, the assoc command provides direct control over the Windows file association registry. IT professionals and system administrators use this command for bulk association management, policy enforcement, and troubleshooting application integration issues.

This comprehensive guide covers assoc syntax, practical examples for viewing and modifying associations, common use cases, troubleshooting tips, related commands, and frequently asked questions. By the end, you'll confidently manage file associations from the command line for system administration, automation, and support tasks.

What Is the Assoc Command?

The assoc command has been part of Windows since the early CMD days, providing direct access to the file association subsystem stored in the Windows Registry. File associations create the link between file extensions (like .txt, .html, .pdf) and file types (like txtfile, htmlfile, pdffile), which in turn determine which application opens each file type.

When you double-click a file in Windows Explorer, the operating system checks the file extension, looks up the associated file type using assoc mappings, and then uses the ftype command to determine which program to launch. The assoc command manages the first part of this chain: extension → file type.

Unlike the Windows Settings app or File Explorer's "Open with" interface, assoc provides command-line power for viewing all associations at once, scripting bulk changes, and managing associations remotely or in automation workflows. The command works in Command Prompt (CMD), works with some limitations in PowerShell, and is available in all modern Windows versions including Windows 11, Windows 10, Windows 8, Windows 7, and Windows Server editions.

Assoc Command Syntax

The basic syntax for the assoc command is:

assoc [.ext[=[fileType]]]

Parameters

ParameterDescription
.extThe file extension to display or modify (include the period, e.g., .txt)
fileTypeThe file type name to associate with the extension (e.g., txtfile)
(no parameters)Display all current file extension associations

Common Usage Patterns

Display all associations:

assoc

Display association for specific extension:

assoc .txt

Set or change association:

assoc .log=txtfile

Remove association:

assoc .xyz=

Setting the file type to an empty value (.ext=) removes the association entirely. This causes Windows to prompt "How do you want to open this file?" when users attempt to open files with that extension.

Understanding File Extensions and File Types

File associations work in two layers:

  1. Extension → File Type (managed by assoc)
  2. File Type → Program (managed by ftype)

For example, .txt files typically have this association chain:

.txt → txtfile → %SystemRoot%\system32\NOTEPAD.EXE %1

The assoc command manages the first link (.txt → txtfile), while the ftype command manages the second link (txtfile → NOTEPAD.EXE). Together, they determine which program opens .txt files.

File type names are arbitrary identifiers stored in the registry. Common conventions include:

  • txtfile for text files
  • htmlfile for HTML documents
  • jpegfile for JPEG images
  • Word.Document.12 for Microsoft Word documents

You can use any file type name, but using Windows standard names ensures compatibility with existing applications and user expectations.

Practical Assoc Command Examples

Display All File Associations

View all registered file extension associations on the system:

assoc

Output shows extension → file type mappings:

.323=h323file
.aac=WMP11.AssocFile.AAC
.ade=Access.ADEFile.16
.adp=Access.ADPFile.16
.ai=Illustrator.Document
.aif=WMP11.AssocFile.AIFF
.aifc=WMP11.AssocFile.AIFF
.aiff=WMP11.AssocFile.AIFF
.application=ClickOnce.Application
.avi=WMP11.AssocFile.AVI
.bat=batfile
.bmp=Paint.Picture
...

This list can be hundreds of entries long. Pipe through more for paged output: assoc | more.

Check Specific File Extension Association

Display the file type associated with .txt files:

assoc .txt

Output:

.txt=txtfile

This confirms .txt files are associated with the txtfile file type. Use ftype txtfile to see which program opens txtfile types.

Associate a New Extension with Existing File Type

Make .log files open like .txt files by associating them with txtfile:

assoc .log=txtfile

After this command, .log files will open in Notepad (or whatever program is configured for txtfile types). This is useful for making application log files easily readable without changing their extension.

Create Custom File Type Association

Associate .config files with a custom file type for specialized handling:

assoc .config=ConfigurationFile

After creating this association, use ftype ConfigurationFile="C:\Program Files\YourEditor\editor.exe" "%1" to specify which program opens ConfigurationFile types.

Remove File Association

Delete the association for .xyz files:

assoc .xyz=

Windows will prompt users with "How do you want to open this file?" when they attempt to open .xyz files. Useful for resetting problematic associations or removing unwanted file type mappings.

Associate Multiple Extensions with Same File Type

Make .htm and .html both use htmlfile:

assoc .htm=htmlfile
assoc .html=htmlfile

Ensures consistent handling of HTML files regardless of extension variant. Common for web development and content management scenarios.

Fix Broken .exe Association

If .exe files stop launching correctly (a serious system issue), restore the default association:

assoc .exe=exefile

Warning: Incorrect .exe associations can prevent programs from launching. Always verify the correct file type before modifying critical associations like .exe, .com, .bat, .cmd, and .msi.

Batch Association Changes in Scripts

Create a batch file to set multiple associations:

@echo off
echo Setting custom file associations...
assoc .log=txtfile
assoc .conf=txtfile
assoc .ini=inifile
assoc .cfg=txtfile
echo Associations updated successfully.
pause

Save as set-associations.bat and run as Administrator. Useful for deploying standardized file associations across multiple systems.

Export Current Associations for Backup

Save all current associations to a text file:

assoc > file-associations-backup.txt

This creates a backup of current associations for documentation or restoration purposes. Review the file before making bulk changes.

Query Extension Association in Scripts

Check if an extension has an association in a batch script:

assoc .txt | find "txtfile"
if %errorlevel%==0 (
    echo .txt is correctly associated
) else (
    echo .txt association is missing or incorrect
)

Useful for validation scripts that verify system configuration before application installation or updates.

Common Use Cases for the Assoc Command

  1. Troubleshoot file association issues – When files stop opening with the correct program, use assoc .ext to verify the extension → file type mapping is correct. Often the association is intact but the file type → program mapping (ftype) is broken.

  2. Standardize file handling across enterprise systems – Deploy batch scripts with assoc commands to ensure consistent file associations on all workstations, particularly for proprietary file formats or custom applications.

  3. Reset corrupted file associations – System infections, failed software installations, or registry corruption can break file associations. Use assoc to restore default associations for affected extensions.

  4. Configure associations for custom file formats – Applications that use proprietary file extensions need associations configured. Use assoc to map custom extensions to file types, then ftype to specify the program.

  5. Audit file associations for security – Malware sometimes hijacks file associations to launch malicious programs. Use assoc > audit.txt to export associations for security review and comparison against baseline configurations.

  6. Prepare systems for application deployment – Before deploying custom applications, configure required file associations using assoc in installation scripts to ensure proper file handling.

  7. Fix "Open With" problems – When Windows prompts "How do you want to open this file?" for known file types, the assoc mapping may be missing. Restore the association using assoc.

  8. Document system configuration – Export assoc output as part of system documentation for compliance, troubleshooting, or disaster recovery planning.

  9. Manage log file associations – Make various log file extensions (.log, .txt, .trace) all open in the same viewer by associating them with the same file type.

  10. Remove unwanted associations from previous software – After uninstalling applications, orphaned file associations may remain. Use assoc .ext= to remove associations for extensions no longer in use.

  11. Configure portable application environments – In enterprise or educational environments, configure file associations to launch portable applications from network shares or USB drives.

  12. Automate association changes during software updates – When updating custom applications that change file format handling, include assoc commands in update scripts to adjust associations automatically.

Tips and Best Practices

  1. Administrator rights required for changes – Modifying file associations requires running Command Prompt as Administrator. Right-click CMD and select "Run as administrator" before making changes.

  2. Always check before changing – Use assoc .ext to view the current association before modifying it. Document the original value for rollback if needed.

  3. Use standard file type names when possible – Windows has conventions like txtfile, htmlfile, pdffile. Using standard names ensures compatibility with existing applications and user expectations.

  4. Test changes on a single system first – Before deploying association changes across many systems, test on a development or test machine to verify correct behavior.

  5. Combine assoc with ftype – Assoc alone only changes extension → file type mappings. Use ftype to complete the chain and specify which program opens the file type: ftype fileType="C:\Program Files\App\app.exe" "%1".

  6. Quote file paths with spaces – When using ftype after assoc, always quote program paths containing spaces: ftype CustomType="C:\Program Files\My App\app.exe" "%1".

  7. Backup associations before bulk changes – Run assoc > backup.txt before making multiple association changes to document original state.

  8. Avoid modifying system-critical associations – Extensions like .exe, .com, .bat, .cmd, .msi, .scr are critical for system operation. Incorrect associations can prevent Windows from functioning correctly.

  9. Use Group Policy for enterprise-wide associations – For domain environments, consider using Group Policy to manage file associations centrally rather than running scripts on each machine.

  10. Verify changes after applying – Run assoc .ext after making changes to confirm the new association is active. Changes take effect immediately without reboot.

  11. Consider user context – Some file associations are per-user, others system-wide. Running assoc as Administrator typically modifies system-wide associations. User-specific associations may override system settings.

  12. Document changes in deployment scripts – When using assoc in automation, add comments explaining why each association is set to aid future troubleshooting and maintenance.

Troubleshooting Common Issues

"Access is denied" Error

Problem: Assoc command fails with "Access is denied" when trying to modify file associations.

Cause: Insufficient permissions. File association changes require administrator privileges.

Solution:

  • Close Command Prompt and reopen as Administrator (right-click CMD, select "Run as administrator")
  • Verify User Account Control (UAC) is not blocking the change
  • Check if Group Policy is enforcing specific file associations in domain environments
  • Ensure the registry keys HKEY_CLASSES_ROOT\.ext and HKEY_CLASSES_ROOT\fileType are not write-protected

Prevention: Always run CMD as Administrator when planning to modify system configuration including file associations.

Changes Don't Take Effect

Problem: After running assoc, files still open with the wrong program or don't open at all.

Cause: Explorer caching old associations, or the file type → program mapping (ftype) is incorrect even though assoc mapping is correct.

Solution:

  • Refresh Explorer: press F5 or restart explorer.exe via Task Manager
  • Verify the complete association chain: assoc .ext (check extension → file type) and ftype fileType (check file type → program)
  • Check if user-level associations override system associations in Settings → Apps → Default apps
  • Log out and log back in to refresh user session
  • Clear icon cache: ie4uinit.exe -show or delete IconCache.db from %localappdata%

Prevention: Always verify both assoc and ftype after making changes. Test by opening an actual file, not just checking command output.

Cannot Find File Extension

Problem: Running assoc .ext returns "File association not found for extension .ext".

Cause: The specified extension has no registered association in the system.

Solution:

  • This is normal for uncommon or custom file extensions
  • Create a new association: assoc .ext=CustomFileType
  • Then set the program: ftype CustomFileType="C:\Program Files\App\app.exe" "%1"
  • Alternatively, use Windows Settings → Apps → Default apps → Choose default apps by file type

Prevention: When developing custom file formats, include file association setup in application installers.

File Association Reverts After Reboot

Problem: File associations configured with assoc revert to previous values after restarting Windows.

Cause: Group Policy enforcement, user-level associations overriding system associations, or system restore/antivirus resetting registry changes.

Solution:

  • Check Group Policy: gpedit.msc → Computer Configuration → Administrative Templates → Windows Components → File Explorer → Set a default associations configuration file
  • Verify no user-level association overrides exist in Settings → Apps → Default apps
  • Disable system restore temporarily for testing
  • Check if antivirus or security software is reverting registry changes
  • Use DefaultAssociations.xml with Group Policy for persistent domain-wide associations

Prevention: In enterprise environments, use Group Policy to enforce file associations. For standalone systems, document which applications are overriding associations.

Incorrect Association Breaks File Access

Problem: After setting an incorrect association, files won't open or open with the wrong program.

Cause: Typo in file type name, or file type → program mapping doesn't exist for the specified file type.

Solution:

  • Check the file type: ftype fileType to verify it points to a valid program
  • Reset to default: look up the correct Windows default (e.g., .txt=txtfile) and reapply
  • Remove broken association: assoc .ext= then reconfigure through Windows Settings
  • For critical extensions like .exe, restore immediately: assoc .exe=exefile
  • Use system restore if multiple associations are broken and you don't have backups

Prevention: Always document original association before changing: assoc .ext > original.txt. Test on non-critical extensions first.

Assoc Shows Wrong Association but Files Open Correctly

Problem: Assoc command shows unexpected file type, but files open with the correct program anyway.

Cause: User-level associations (configured via Settings → Default apps) override system-level associations displayed by assoc.

Solution:

  • Check user associations: Settings → Apps → Default apps → Choose default apps by file type
  • If system-wide consistency is needed, configure assoc as Administrator and remove user-level overrides
  • In domain environments, use Group Policy to enforce associations and prevent user changes

Prevention: Understand that Windows has multiple layers of file associations (system, user, Group Policy). Assoc only shows/modifies system-level associations.

Related Commands

ftype – Manage File Type Open Commands

While assoc maps extensions to file types (.txt → txtfile), ftype maps file types to programs (txtfile → notepad.exe). Both commands work together to form the complete file association chain.

When to use ftype: After setting an extension association with assoc, use ftype to specify which program opens that file type.

When to use assoc: To change which file type an extension maps to, or to create associations for new extensions.

Example workflow:

assoc .log=txtfile
ftype txtfile=%SystemRoot%\system32\NOTEPAD.EXE %1

This makes .log files open in Notepad by associating them with txtfile type and ensuring txtfile opens with Notepad.

ftype – Display File Type Program Mappings

Use ftype without parameters to display all file type → program mappings, or ftype fileType to show a specific mapping.

Example: ftype htmlfile shows which program opens htmlfile types (typically the default web browser).

reg – Direct Registry Access

The reg command provides low-level access to the Windows Registry where file associations are stored. Use for advanced association management, exporting/importing configurations, or troubleshooting when assoc doesn't work.

Registry locations:

  • HKEY_CLASSES_ROOT\.ext – extension → file type mappings (assoc)
  • HKEY_CLASSES_ROOT\fileType\shell\open\command – file type → program (ftype)

Example: reg query HKCR\.txt shows registry data for .txt extension.

Advanced users: Use reg export/import for backing up and restoring file associations across systems.

DefaultAssociationsConfiguration.xml – Group Policy File Associations

For enterprise environments, use DefaultAssociationsConfiguration.xml with Group Policy to deploy file associations domain-wide. This method overrides user preferences and provides centralized management.

Workflow:

  1. Configure associations on a reference machine
  2. Export: Dism.exe /Online /Export-DefaultAppAssociations:C:\associations.xml
  3. Deploy via Group Policy: Computer Configuration → Administrative Templates → Windows Components → File Explorer → Set a default associations configuration file
  4. Point to network path with associations.xml

Advantage: Centralized management, user-override prevention, automated deployment to all domain machines.

Start – Test File Associations

The start command opens files with their associated programs, providing a quick way to test associations after changes.

Example: start test.txt opens test.txt with the program associated with .txt files (typically Notepad).

Testing workflow: After modifying associations with assoc and ftype, use start to verify files open correctly: start example.log should now open in Notepad if you associated .log=txtfile.

assoc and ftype in PowerShell

PowerShell has limited native support for file associations. Use cmd /c assoc and cmd /c ftype to run CMD commands from PowerShell:

cmd /c assoc .txt
cmd /c "assoc .log=txtfile"

For PowerShell-native approaches, manipulate the registry directly using Get-ItemProperty and Set-ItemProperty with registry paths like HKCR:\.txt.

Frequently Asked Questions

What does assoc .txt do?

assoc .txt displays the file type associated with .txt files. Output like .txt=txtfile shows that .txt files are mapped to the txtfile file type. Use ftype txtfile to see which program opens txtfile types (typically Notepad).

How do I change file associations with assoc?

Use assoc .ext=fileType to change an extension's association. Example: assoc .log=txtfile makes .log files use the same file type as .txt files. Remember to run Command Prompt as Administrator for changes to take effect.

What is the difference between assoc and ftype?

Assoc maps file extensions to file types (.txt → txtfile). Ftype maps file types to programs (txtfile → notepad.exe). Both work together: assoc determines the file type for an extension, then ftype determines which program opens that file type.

Can I remove a file association with assoc?

Yes, use assoc .ext= (with no file type after the equals sign) to remove an association. Example: assoc .xyz= removes the association for .xyz files, causing Windows to prompt "How do you want to open this file?" when users attempt to open them.

How do I backup all file associations?

Run assoc > associations-backup.txt to save all current associations to a text file. For complete backup including ftype mappings, also run ftype > ftype-backup.txt. Store these files for documentation or restoration purposes.

Do I need administrator rights to use assoc?

Viewing associations with assoc (no parameters or assoc .ext) doesn't require administrator rights. Modifying associations with assoc .ext=fileType requires running Command Prompt as Administrator.

Why don't my assoc changes take effect?

Common causes: Explorer caching old associations (press F5 to refresh), user-level associations overriding system settings (check Settings → Default apps), or Group Policy enforcement in domain environments. Try logging out and back in, or verify with assoc .ext that the change was saved.

Can assoc work with network drives or remote systems?

Assoc modifies the local registry and only affects the local system. For remote association management, use remote registry editing, PowerShell remoting with Invoke-Command, or Group Policy in domain environments. Assoc itself doesn't support remote system parameters.

How do I restore default Windows file associations?

For common extensions, use Windows defaults: assoc .txt=txtfile, assoc .html=htmlfile, assoc .jpg=jpegfile. For comprehensive restoration, use Windows Settings → Apps → Default apps → Reset to set all associations to Microsoft-recommended defaults.

What happens if I associate .exe with the wrong file type?

Incorrect .exe associations prevent programs from launching, which is a serious system issue. Immediately restore: assoc .exe=exefile. If CMD won't run due to broken .exe association, boot into Safe Mode or use regedit to manually fix: HKEY_CLASSES_ROOT\.exe should have default value exefile.

Can I use assoc in batch scripts?

Yes, assoc is commonly used in installation scripts, system configuration scripts, and maintenance tasks. Example:

@echo off
assoc .log=txtfile
assoc .conf=txtfile
echo Associations configured.

Always run batch files with administrator privileges when modifying associations.

How do I find which program opens a file type?

First, use assoc .ext to find the file type, then use ftype fileType to see the program. Example: assoc .txt shows .txt=txtfile, then ftype txtfile shows txtfile=%SystemRoot%\system32\NOTEPAD.EXE %1.

Quick Reference Card

CommandPurposeExample Use Case
assocDisplay all associationsAudit system configuration
assoc .txtShow .txt associationVerify specific extension
assoc .log=txtfileAssociate .log with txtfileMake logs open in Notepad
assoc .xyz=Remove .xyz associationClean up orphaned associations
assoc > backup.txtExport all associationsBackup before changes
assoc .ext | find "="Check if association existsValidation in scripts
assoc .html=htmlfileSet HTML associationFix broken browser associations
assoc .exe=exefileRestore .exe associationEmergency fix for broken executables

Try the Assoc Command in Our Simulator

Practice the assoc command safely in our Windows Command Simulator. No installation required—run assoc, assoc .txt, and other examples in your browser. Perfect for learning, testing commands before running them on production systems, or demonstrating assoc functionality in training environments.

Visit the Commands Reference for a full list of supported Windows CMD commands, including file management, system configuration, and administration utilities.

Summary

The assoc command is essential for managing file extension associations in Windows Command Prompt. Use assoc .ext=fileType to map file extensions to file types, which in turn determine which programs open files. View all associations with assoc alone, or check specific extensions with assoc .ext.

File associations work in a two-layer system: assoc maps extensions to file types (.txt → txtfile), and ftype maps file types to programs (txtfile → notepad.exe). Both commands work together to form the complete association chain that determines how Windows handles file opening.

Master assoc for system administration tasks like troubleshooting file association issues, standardizing file handling across enterprise environments, configuring associations for custom applications, and auditing system configuration for security or compliance. The command's simplicity and direct registry access make it indispensable for IT professionals managing Windows file handling.

Remember to run Command Prompt as Administrator when modifying associations, always verify changes with assoc .ext after applying them, and test with actual files to ensure the complete association chain (assoc + ftype) works correctly. For enterprise-wide management, consider Group Policy with DefaultAssociationsConfiguration.xml for centralized control.