次の方法で共有


ftype

ファイル名拡張子の関連付けに使用されるファイルの種類を表示または変更します。 代入演算子 (=) なしで使用した場合、このコマンドは、指定されたファイルの種類の現在の開いているコマンド文字列を表示します。 パラメーターを指定せずに使用した場合、このコマンドは、開いているコマンド文字列が定義されているファイルの種類を表示します。

Note

このコマンドは、cmd.exe 内でのみサポートされており、PowerShell からは使用できません。 ただし、回避策として cmd /c ftype を使用できます。

Syntax

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

Parameters

Parameter Description
<filetype> 表示または変更するファイルの種類を指定します。
<opencommandstring> 指定したファイルの種類のファイルを開くときに使用する open コマンド文字列を指定します。
/? コマンド プロンプトにヘルプを表示します。

Remarks

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

Variable Replacement value
%0 または %1 関連付けを通じて起動されるファイル名に置き換えられる値を取得します。
%* すべてのパラメーターを取得します。
%2%3、 ... 最初のパラメーター (%2)、2 番目のパラメーター (%3) などを取得します。
%~<n> Gets all of the remaining parameters starting with the nth parameter, where n can be any number from 2 to 9.

Examples

開いているコマンド文字列が定義されている現在のファイルの種類を表示するには、次のように入力します。

ftype

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

ftype txtfile

このコマンドを実行すると、次のような出力が生成されます。

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

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

ftype example=

.plファイル名拡張子を PerlScript ファイルの種類に関連付け、PerlScript ファイルの種類でPERL.EXE実行できるようにするには、次のコマンドを入力します。

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

Perl スクリプトを呼び出すときに.plファイル名拡張子を入力する必要をなくすには、次のように入力します。

set PATHEXT=.pl;%PATHEXT%