2

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 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.