共用方式為


ftype

顯示或修改擴展名關聯中使用的檔案類型。 如果不使用指派運算符 (=),此命令會顯示指定檔類型的目前開啟命令字串。 如果沒有參數使用,此命令會顯示已定義開啟命令字串的檔案類型。

Note

此命令僅在 cmd.exe 內受到支援,且無法從PowerShell取得。 雖然您可以使用 cmd /c ftype 作為因應措施。

Syntax

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

Parameters

Parameter Description
<filetype> 指定要顯示或變更的檔案類型。
<opencommandstring> 指定開啟指定檔案類型之檔案時要使用的開啟命令字串。
/? 在命令提示字元中顯示說明。

Remarks

下表說明 ftype 如何取代開啟命令字串內的變數:

Variable Replacement value
%0%1 以透過關聯啟動的檔案名稱取代 。
%* 取得所有參數。
%2%3... 取得第一個參數 (%2),第二個參數 (%3),依此等。
%~<n> 取得從 第 n個參數開始的所有剩餘參數,其中 n 可以是 2 到 9 之間的任何數字。

Examples

若要顯示已定義開啟命令字串的目前檔案類型,請輸入:

ftype

若要顯示 txtfile 檔案類型的目前開啟的命令字串,請鍵入:

ftype txtfile

這個指令會產生類似下列的輸出:

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

若要刪除名為 example 的檔案類型的開啟命令字串,請輸入:

ftype example=

若要將.pl擴展名與 PerlScript 檔類型產生關聯,並讓 PerlScript 檔類型執行PERL.EXE,請輸入下列命令:

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

若要排除在叫用 Perl 腳本時輸入.pl擴展名的需求,請輸入:

set PATHEXT=.pl;%PATHEXT%