CMD Simulator
File Systemftype

FTYPE Command Guide - Manage File Type Associations in Windows

Learn how to use the ftype command to view and modify file type associations that link file extensions to executable programs in Windows Command Prompt. Includes syntax, examples, and troubleshooting tips.

Rojan Acharya·
Share

The ftype command is a Windows Command Prompt utility that displays and modifies file type associations, which define the executable programs and commands used to open specific file types. Use ftype to list all file type associations, ftype txtfile to view the command for opening text files, or ftype txtfile=notepad.exe %1 to change the default program for text files directly from the command line.

Whether you're troubleshooting file association issues, resetting default programs after malware infections, automating application configurations across multiple systems, or managing custom file types for enterprise deployments, mastering ftype provides granular control over how Windows handles different file extensions. IT professionals and system administrators rely on this command for fixing broken associations, standardizing default applications, and scripting system configurations.

This comprehensive guide covers ftype syntax, relationship with assoc command, practical examples for viewing and modifying associations, common file types, troubleshooting tips, automation techniques, related commands, and frequently asked questions. By the end, you'll confidently manage file type associations from the command line for system administration, troubleshooting, and deployment automation.

What Is the Ftype Command?

The ftype command manages file type associations in Windows, which define how files are opened based on their extensions. File associations work in two layers:

  1. File extension to file type (managed by assoc command)

    • Example: .txttxtfile
    • Maps extension to a file type identifier
  2. File type to executable command (managed by ftype command)

    • Example: txtfile%SystemRoot%\system32\NOTEPAD.EXE %1
    • Maps file type identifier to program that opens it

How File Associations Work

When you double-click document.txt:

  1. Windows checks extension: .txt
  2. Runs assoc .txt → returns txtfile
  3. Runs ftype txtfile → returns notepad.exe %1
  4. Executes: notepad.exe document.txt

The %1 parameter represents the filename being opened. Additional parameters (%2, %3, etc.) pass multiple arguments.

Ftype vs. Assoc

CommandPurposeExample
assocMaps extension to file type.txttxtfile
ftypeMaps file type to commandtxtfilenotepad.exe %1
RelationshipAssoc defines type; ftype defines actionBoth work together

Typical workflow: Use assoc .ext=FileType to map extension, then ftype FileType=command to define what opens it.

The command works in Command Prompt (CMD) with administrator privileges for modifications. Available in Windows 11, Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, and all Windows Server editions.

Ftype Command Syntax

The basic syntax for the ftype command is:

ftype [FileType[=[OpenCommandString]]]

Parameters

ParameterDescription
FileTypeFile type identifier to display or modify (e.g., txtfile, htmlfile)
OpenCommandStringCommand string that defines how to open files of this type
(no parameters)Displays all file types with current command strings
FileType=Deletes the association for specified file type

Command String Variables

VariableMeaning
%1First parameter (filename being opened)
%*All parameters
%2, %3, etc.Additional parameters
%LLong filename (for 8.3 vs. long name scenarios)
%SShort filename (8.3 format)

Administrator Privileges

Important: Modifying file type associations requires administrator privileges. Right-click Command Prompt → "Run as administrator" before changing associations.

Viewing File Type Associations

List All File Types

To display all registered file types:

ftype

Output (partial):

txtfile=%SystemRoot%\system32\NOTEPAD.EXE %1
htmlfile="C:\Program Files\Internet Explorer\iexplore.exe" %1
jpegfile=%SystemRoot%\System32\rundll32.exe "%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll", ImageView_Fullscreen %1

Hundreds of file types displayed. Use ftype | more to page through results or ftype | findstr "search" to filter.

View Specific File Type

To check command for specific file type:

ftype txtfile

Output:

txtfile=%SystemRoot%\system32\NOTEPAD.EXE %1

Shows exact command used to open .txt files (via assoc .txttxtfile mapping).

Filter File Types

To search for specific file types:

ftype | findstr "Python"

Output:

Python.File="C:\Python39\python.exe" "%1" %*
Python.CompiledFile="C:\Python39\python.exe" "%1" %*

Finds all file types containing "Python". Useful for locating associations for specific applications.

Check HTML File Association

To see what opens HTML files:

ftype htmlfile

Output:

htmlfile="C:\Program Files\Google\Chrome\Application\chrome.exe" -- "%1"

Shows current browser associated with HTML files.

Check Office Document Associations

To view Word document handler:

ftype Word.Document.12

Output:

Word.Document.12="C:\Program Files\Microsoft Office\Office16\WINWORD.EXE" /n "%1"

Shows Microsoft Word as handler with /n flag for new instance.

Modifying File Type Associations

Change Text File Association

To change default program for text files:

ftype txtfile="C:\Program Files\Notepad++\notepad++.exe" %1

Changes text file handler from Notepad to Notepad++. After this, double-clicking .txt files opens Notepad++.

Prerequisites:

  1. Run Command Prompt as administrator
  2. Verify file extension is mapped: assoc .txt should return txtfile

Set Python File Handler

To associate Python files with Python interpreter:

ftype Python.File="C:\Python39\python.exe" "%1" %*

Configures .py files to run with Python interpreter. %* passes all command-line arguments to script.

Configure HTML Files to Open in Browser

To set Chrome as default for HTML files:

ftype htmlfile="C:\Program Files\Google\Chrome\Application\chrome.exe" -- "%1"

HTML files now open in Chrome. The -- separates Chrome flags from the file parameter.

Set Custom File Type

To create custom file type association:

assoc .custom=CustomFileType
ftype CustomFileType="C:\MyApp\myprogram.exe" "%1"

Two-step process:

  1. Map .custom extension to CustomFileType identifier
  2. Map CustomFileType to executable program

Now .custom files open with myprogram.exe.

Add Command-Line Flags

To open files with specific application flags:

ftype pdffile="C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /n "%1"

The /n flag opens PDF in new window. Customize flags based on application requirements.

Reset to Default Association

To reset file type to Windows default:

ftype txtfile=

Deletes custom association. Windows reverts to built-in default (usually Notepad for text files).

Note: This removes the association entirely. To restore to specific program, set explicit command string.

Common File Type Examples

Text Files (txtfile)

Default text file association:

ftype txtfile

Common modifications:

ftype txtfile="C:\Program Files\Notepad++\notepad++.exe" %1
ftype txtfile="C:\Program Files\Visual Studio Code\Code.exe" "%1"
ftype txtfile="C:\Program Files\Sublime Text\sublime_text.exe" "%1"

Python Files (Python.File)

View Python association:

ftype Python.File

Set Python 3.9:

ftype Python.File="C:\Python39\python.exe" "%1" %*

Set Python 3.10:

ftype Python.File="C:\Python310\python.exe" "%1" %*

JavaScript Files (JSFile)

View JavaScript association:

ftype JSFile

Set Node.js handler:

ftype JSFile="C:\Program Files\nodejs\node.exe" "%1" %*

Batch Files (batfile)

View batch file association:

ftype batfile

Output:

batfile=%SystemRoot%\System32\cmd.exe /c "%1" %*

Batch files execute via cmd.exe. Generally should not be modified.

Registry Files (regfile)

View registry file association:

ftype regfile

Output:

regfile="regedit.exe" "%1"

Opens .reg files in Registry Editor. Warning: Modifying this can prevent registry imports.

PDF Files (AcroExch.Document.DC)

View PDF association:

ftype AcroExch.Document.DC

Change to Adobe Acrobat:

ftype AcroExch.Document.DC="C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" "%1"

Change to browser:

ftype AcroExch.Document.DC="C:\Program Files\Google\Chrome\Application\chrome.exe" "%1"

Image Files (jpegfile, pngfile)

View JPEG association:

ftype jpegfile

Set Photos app (Windows 10/11):

ftype jpegfile=%SystemRoot%\System32\rundll32.exe "%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll", ImageView_Fullscreen %1

Set Paint.NET:

ftype jpegfile="C:\Program Files\paint.net\PaintDotNet.exe" "%1"

Office Documents (Word.Document.12, Excel.Sheet.12)

View Word document association:

ftype Word.Document.12

View Excel spreadsheet association:

ftype Excel.Sheet.12

These typically point to Microsoft Office applications. Modify with caution—incorrect associations break Office functionality.

Automation and Scripting

Batch Script to Set Multiple Associations

Create set_associations.bat:

@echo off
echo Setting file associations...

ftype txtfile="C:\Program Files\Notepad++\notepad++.exe" %1
ftype Python.File="C:\Python39\python.exe" "%%1" %%*
ftype htmlfile="C:\Program Files\Google\Chrome\Application\chrome.exe" -- "%%1"

echo Associations set successfully.
pause

Note: In batch files, use %%1 instead of %1 for parameters (double percent signs).

PowerShell Script for Association Management

Create Set-FileAssociations.ps1:

# Requires administrator privileges
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
    Write-Error "Run as Administrator"
    exit
}

# Set associations
cmd /c 'ftype txtfile="C:\Program Files\Notepad++\notepad++.exe" %1'
cmd /c 'ftype Python.File="C:\Python39\python.exe" "%1" %*'

Write-Host "Associations updated successfully"

Run: powershell -ExecutionPolicy Bypass -File Set-FileAssociations.ps1

Export Current Associations

Save all associations to file:

ftype > file_associations_backup.txt

Documents current state. Useful before making changes for rollback capability.

Restore Associations from Backup

To restore specific association:

ftype txtfile="C:\Windows\System32\notepad.exe" %1

Manually restore from backup file by re-running relevant ftype commands.

Deploy Standard Associations Across Enterprise

Use Group Policy or login script to standardize associations:

@echo off
REM Enterprise standard associations
ftype txtfile="%ProgramFiles%\Notepad++\notepad++.exe" %%1
ftype Python.File="%ProgramFiles%\Python39\python.exe" "%%1" %%*
ftype htmlfile="%ProgramFiles%\Google\Chrome\Application\chrome.exe" -- "%%1"

Deploy via GPO startup script or configuration management tool.

Troubleshooting File Association Issues

File Opens with Wrong Program

Problem: Files open with incorrect application despite correct icon.

Cause: File type association is incorrect or file extension is mapped to wrong file type.

Solution:

  1. Check extension mapping: assoc .txt (should return correct file type like txtfile)
  2. Check file type command: ftype txtfile (should point to desired program)
  3. Fix extension mapping if wrong: assoc .txt=txtfile
  4. Fix file type command: ftype txtfile="C:\Path\To\Program.exe" %1

Prevention: Always verify both assoc and ftype when setting associations.

"Access is Denied" When Modifying

Problem: Ftype command fails with access denied error.

Cause: Insufficient privileges—ftype modifications require administrator rights.

Solution:

  1. Close Command Prompt
  2. Right-click Command Prompt icon → "Run as administrator"
  3. Re-run ftype command

Prevention: Always use elevated Command Prompt for ftype modifications.

Association Changes Don't Take Effect

Problem: Modified file type association but files still open with old program.

Cause: Explorer cache hasn't refreshed, or user-specific associations override system associations.

Solution:

  1. Restart Explorer: taskkill /f /im explorer.exe then start explorer.exe
  2. Log off and back on
  3. Check for user-specific overrides in Settings → Default Apps
  4. Clear user choices: Delete registry key HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\<.ext>\UserChoice (advanced)

Prevention: Test associations immediately after changes; refresh Explorer or restart if needed.

Ftype Returns "File Type Not Found"

Problem: Query for file type returns "File type not found".

Cause: File type identifier doesn't exist in registry.

Solution:

  1. Verify file type name: ftype | findstr "keyword" to find correct identifier
  2. Check extension mapping: assoc .ext to see what file type it maps to
  3. Create file type if needed: ftype NewFileType="C:\Program\app.exe" %1

Prevention: Use assoc to confirm file type identifier before querying with ftype.

Broken Association After Software Uninstall

Problem: Files don't open after uninstalling associated application.

Cause: Application removed but file type association still points to non-existent executable.

Solution:

  1. Check current association: ftype FileType
  2. Set new association: ftype FileType="C:\NewProgram\app.exe" %1
  3. Or reset to default: ftype FileType=

Prevention: Document file type associations before uninstalling software; set alternative associations proactively.

Malware Changed File Associations

Problem: Suspicious programs open files; icons changed unexpectedly.

Cause: Malware modified file associations to launch malicious executables.

Solution:

  1. Run antivirus/antimalware scan
  2. Export clean associations: ftype > associations_clean.txt (from known-good system)
  3. Check suspicious associations: ftype | findstr "exe" (look for unexpected paths)
  4. Reset critical associations:
    ftype txtfile=%SystemRoot%\system32\NOTEPAD.EXE %1
    ftype exefile=%1 %*
    ftype batfile=%SystemRoot%\System32\cmd.exe /c "%1" %*
    
  5. Verify with assoc: assoc .exe=exefile, assoc .bat=batfile

Prevention: Keep antivirus updated; avoid modifying critical file types (.exe, .bat, .cmd) unless necessary.

Related Commands

assoc – File Extension Associations

assoc maps file extensions to file type identifiers. Use assoc .txt to see what file type .txt maps to, then ftype txtfile to see the command. Always use assoc before ftype—assoc defines the type, ftype defines the action.

reg – Registry Editor

reg command accesses registry directly. File associations are stored in registry under HKEY_CLASSES_ROOT. Use reg query HKCR\.txt to see extension data, reg query HKCR\txtfile for file type data. Ftype is higher-level interface to same registry data.

start – Open Files

start opens files with associated programs. After setting associations with ftype, test with start filename.txt to verify correct program opens. Start respects ftype associations.

control – Control Panel

control opens Control Panel. Use control /name Microsoft.DefaultPrograms to access GUI for default program settings. Ftype provides command-line alternative to GUI association management.

powershell – PowerShell Environment

PowerShell cmdlets like Get-ItemProperty and Set-ItemProperty can manipulate registry-based associations. Use ftype for simpler command-line interface or PowerShell for scripted, object-based management.

cmd – Command Processor

cmd executes batch files and commands. Batch file association (batfile) defines how cmd executes .bat files. Ftype configures file types; cmd uses those configurations.

Frequently Asked Questions

What does ftype do in Windows?

The ftype command displays and modifies file type associations that define which programs open specific file types. Use ftype to list all associations, ftype txtfile to view text file handler, or ftype txtfile=notepad.exe %1 to set the default program for text files.

What's the difference between assoc and ftype?

assoc maps file extensions to file type identifiers (.txttxtfile), while ftype maps file type identifiers to executable commands (txtfilenotepad.exe %1). Both work together: assoc defines the type, ftype defines what opens it.

How do I change the default program for a file type?

Two steps: 1) Verify extension mapping with assoc .ext (e.g., assoc .txt returns txtfile), 2) Set file type command with ftype FileType="C:\Program\app.exe" %1. Example: ftype txtfile="C:\Program Files\Notepad++\notepad++.exe" %1 sets Notepad++ for text files.

Do I need administrator privileges for ftype?

Yes, modifying file type associations requires administrator privileges. Right-click Command Prompt → "Run as administrator". Viewing associations (ftype without parameters) works without elevation, but changes require admin rights.

What does %1 mean in ftype commands?

%1 represents the filename being opened. When you double-click document.txt, Windows executes the ftype command with %1 replaced by document.txt. Example: notepad.exe %1 becomes notepad.exe document.txt.

How do I reset file associations to default?

Use ftype FileType= to delete custom association. Windows reverts to built-in default. Example: ftype txtfile= resets text files to Windows default (Notepad). Alternatively, set explicit default: ftype txtfile=%SystemRoot%\system32\NOTEPAD.EXE %1.

Can I set different programs for the same extension?

No, each file extension maps to one file type, and each file type has one command. However, you can create multiple file type identifiers and use assoc to switch between them. Or use context menu "Open with" for per-instance program selection.

How do I fix file associations after malware?

Run antivirus first, then reset critical associations: ftype exefile=%1 %*, ftype batfile=%SystemRoot%\System32\cmd.exe /c "%1" %*, ftype txtfile=%SystemRoot%\system32\NOTEPAD.EXE %1. Verify extension mappings: assoc .exe=exefile, assoc .bat=batfile, assoc .txt=txtfile.

What are common file type identifiers?

Common identifiers: txtfile (text), htmlfile (HTML), jpegfile (JPEG images), pngfile (PNG images), Python.File (Python scripts), batfile (batch files), exefile (executables), Word.Document.12 (Word docs), Excel.Sheet.12 (Excel sheets). Use ftype | findstr "keyword" to find others.

How do I export file associations for backup?

Run ftype > associations_backup.txt to save all associations to text file. To restore specific association, reference backup file and manually run ftype FileType=command commands. For full backup including assoc mappings, also run assoc > extensions_backup.txt.

Can ftype associations be set per user?

System-level associations (set with admin ftype) apply to all users. User-specific associations are typically set via GUI (Default Apps settings) and stored in user registry (HKCU). Command-line ftype operates at system level (HKCR). User choices can override system defaults.

Why do my changes not take effect immediately?

Windows Explorer caches file associations. Solutions: 1) Restart Explorer (taskkill /f /im explorer.exe then start explorer.exe), 2) Log off and back on, 3) Restart computer. For immediate testing, use start filename.ext from command prompt instead of double-clicking.

Quick Reference Card

CommandPurposeExample
ftypeList all file typesView all associations
ftype txtfileView specific typeCheck text file handler
ftype txtfile=notepad.exe %1Set associationChange default program
ftype FileType=Reset associationRemove custom handler
ftype | findstr "Python"Search file typesFind specific associations
assoc .txtCheck extensionGet file type identifier
assoc .txt=txtfileSet extensionMap extension to type
ftype > backup.txtExport associationsBackup current state

Try Ftype in Our Simulator

Want to practice using the ftype command without affecting your system? Try our interactive Windows Command Simulator to experiment with file type associations, view associations, and understand the relationship between assoc and ftype in a safe, simulated environment. Practice command syntax and test association queries before running commands on your actual system.

For more file system commands, browse our comprehensive Commands Reference with over 200 Windows commands, syntax guides, and practical examples.

Summary

The ftype command provides essential file type association management for controlling which programs open specific file types in Windows through command-line configuration. By displaying file type associations and modifying the executable commands that handle different file types, you can troubleshoot broken associations, standardize default applications, and automate file handling configurations across systems.

Key takeaways: Use ftype without parameters to list all file type associations in the system. Query specific file types with ftype txtfile to see the command that opens text files. Modify associations with ftype FileType="C:\Program\app.exe" %1 where %1 represents the filename being opened. Reset associations to defaults with ftype FileType= to remove custom handlers.

Understand the two-layer system: assoc maps file extensions to file type identifiers (.txttxtfile), while ftype maps file type identifiers to executable commands (txtfilenotepad.exe %1). Always verify both layers when troubleshooting association issues. Use assoc .ext first to confirm file type identifier, then ftype FileType to check or modify the handler.

For system administrators and IT professionals, ftype is essential for fixing broken associations after software installations or malware infections, deploying standardized application configurations across enterprise environments via scripts or Group Policy, and troubleshooting file handling issues. Combine with assoc for complete control over how Windows handles file extensions.

Master the ftype command to manage file type associations, troubleshoot file opening issues, automate application configurations, and maintain consistent file handling behavior—all through efficient command-line administration without requiring GUI navigation or registry editing.