Cmd.exe - what do these symbols mean in ftype command?

1

Just trying to understand something here.. In playing around with file extensions, type assoc .bat and get .bat=batfile, then ftype batfile and get "%1" %*. The same happens with ".exe". Whereas when I run ftype for word.document.12 I get the path for WINWORD.EXE.

My question is, what do the "%1" %* symbols mean from when I run ftype batfile? Thank you!

user1330287

Posted 2017-05-30T08:30:58.220

Reputation: 69

Answers

3

They are described in the help accessed via ftype /?.

Basically, the %1 refers to the filename, while %* gets every argument passed to the file that has been executed. These are in the same format as cmd.exe's own parameter handling, as used in batch files.

Text taken from ftype /?:

.................................................  Within an open
command string %0 or %1 are substituted with the file name being
launched through the assocation.  %* gets all the parameters and %2
gets the 1st parameter, %3 the second, etc.  %~n gets all the remaining
parameters starting with the nth parameter, where n may be between 2 and 9,
inclusive.  For example:

    ASSOC .pl=PerlScript
    FTYPE PerlScript=perl.exe %1 %*

would allow you to invoke a Perl script as follows:

    script.pl 1 2 3

Bob

Posted 2017-05-30T08:30:58.220

Reputation: 51 526