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

ftype

· 52CE 我爱测

Reference article for the ftype command, which displays or modifies file type used in file name extension associations.

Displays or modifies file types that are used in file name extension associations. If used without an assignment operator (=), this command displays the current open command string for the specified file type. If used without parameters, this command displays the file types that have open command strings defined.

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

Syntax

ftype [<filetype>[=[<opencommandstring>]]]

Parameters

Parameter Description
<filetype> Specifies the file type to display or change.
<opencommandstring> Specifies the open command string to use when opening files of the specified file type.
/? Displays help at the command prompt.
Remarks

The following table describes how ftype substitutes variables within an open command string:

Variable Replacement value
%0 or %1 Gets substituted with the file name being launched through the association.
%* Gets all of the parameters.
%2, %3, ... Gets the first parameter (%2), the second parameter (%3), and so on.
%~<n> Gets all of the remaining parameters starting with the nth parameter, where n can be any number from 2 to 9.

Examples

To display the current file types that have open command strings defined, type:

ftype

To display the current open command string for the txtfile file type, type:

ftype txtfile

This command produces output similar to the following:

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

To delete the open command string for a file type called example, type:

ftype example=

To associate the .pl file name extension with the PerlScript file type and enable the PerlScript file type to run PERL.EXE, type the following commands:

assoc .pl=PerlScript
ftype PerlScript=perl.exe %1 %*

To eliminate the need to type the .pl file name extension when invoking a Perl script, type:

set PATHEXT=.pl;%PATHEXT%

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)

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

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