ftypeftype

显示或修改在文件扩展名关联中使用的文件类型。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.

备注

此命令仅在 cmd.exe 中受支持,并且在 PowerShell 中不可用。This command is only supported within cmd.exe and is not available from PowerShell. 尽管可以使用 cmd /c ftype 作为解决方法。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> 指定打开指定文件类型的文件时要使用的 open 命令字符串。Specifies the open command string to use when opening files of the specified file type.
/?/? 在命令提示符下显示帮助。Displays help at the command prompt.

备注Remarks

下表说明了 ftype 如何在打开的命令字符串内替换变量:The following table describes how ftype substitutes variables within an open command string:

变量Variable 替换值Replacement value
%0%1%0 or %1 替换为通过关联启动的文件名。Gets substituted with the file name being launched through the association.
%* 获取所有参数。Gets all of the parameters.
%2, %3, ...%2, %3, ... 获取 () 的第一个参数 %2 ,第二个参数 (%3) ,依此类推。Gets the first parameter (%2), the second parameter (%3), and so on.
%~<n> 获取以第 n个参数开头的所有剩余参数,其中 n 可以是从2到9的任意数字。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

若要显示 txtfile 文件类型的当前打开的命令字符串,请键入: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

若要删除名为 " example" 的文件类型的 "打开命令字符串",请键入:To delete the open command string for a file type called example, type:

ftype example=

若要将 pl 文件扩展名与 PerlScript 文件类型关联并使 PerlScript 文件类型 PERL.EXE 运行,请键入以下命令: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 %*

若要在调用 Perl 脚本时不再需要键入 pl 文件扩展名,请键入:To eliminate the need to type the .pl file name extension when invoking a Perl script, type:

set PATHEXT=.pl;%PATHEXT%

其他参考Additional References