大网数据广告活动
Windows排障命令

assoc

· 52CE 我爱测

Reference article for the assoc command, which displays or modifies file name extension associations.

Displays or modifies file name extension associations. If used without parameters, assoc displays a list of all the current file name extension associations.

Note: This command is only supported within cmd.exe and is not available from PowerShell. Though you can use cmd /c assoc as a workaround.

Syntax

assoc [<.[ext]>[=[<filetype>]]]

Note: In the syntax, square brackets [ ] indicate optional items and angle brackets < > indicate placeholder values that you replace with your own text. Don't type the brackets. For example, to remove the association for the .jar file name extension, type assoc .jar=, not assoc .jar=<filetype>. If you type the angle brackets, cmd.exe treats < and > as redirection operators and returns an error. For more information, see Command-Line Syntax Key.

Parameters

Parameter Description
<.ext> Specifies the file name extension.
<filetype> Specifies the file type to associate with the specified file name extension.
/? Displays help at the command prompt.

Remarks

  • To make changes in associations, you need administrator privileges.

  • To remove the file type association for a file name extension, type the extension and an equal sign with nothing after it, for example assoc .ext=. You don't need to add a trailing space after the equal sign.

  • To associate files without extension to a file type, use just a dot (see the examples).

  • To view current file types that have open command strings defined, use the ftype command.

  • To redirect the output of assoc to a text file, use the > redirection operator.

Examples

To view the current file type association for the file name extension .txt, type:

assoc .txt

To remove the file type association for the file name extension .bak, type:

assoc .bak=

Type nothing after the equal sign. Don't type placeholder text such as <filetype>, and don't add a trailing space.

To remove the file type association for the file name extension .jar, type:

assoc .jar=

To view the output of assoc one screen at a time, type:

assoc | more

To send the output of assoc to the file assoc.txt, type:

assoc>assoc.txt

Associate .log to text files:

assoc .log=txtfile

Associate files with no extension to text files:

assoc .=txtfile

Related links

Source: Microsoft Learn / Windows Server documentation by Microsoft and contributors (upstream author metadata: robinharwood). Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Server documentation
适用范围
Windows Server · Source date 10/16/2017
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。