I've been given the task of writing a script that associated a program (lets say C:\foo.exe) with a custom file-type (lets say .bar). I know it involves editing the settings in the registry, but I have no clue how to do that for custom file-type via a script. Any ideas???
1 Answer
You'll need two commands.
First is ASSOC which is used to modify file extension associations. It takes a parameter in the form of .ext=fileType where .ext is your specific extension and filetype will map to the actual command to be executed.
The filetype can be added with the FTYPE command which modifies file types used in file extension associations. It takes as parameter fileType=openCommandString where our openCommandString will be the program to execute, with the parameters replaced in %1 etc.
Combining those two commands for your specific case will look like this:
ASSOC .bar=Bar2Foo
FTYPE Bar2Foo=c:\foo.exe %1 %*
Notice that you can run ASSOC .bar and FTYPE Bar2Foo to verify if the results are as you expect.