Search code examples
cmdfile-typefile-association

Is it possible to associate a file type with a .cmd file so it sends that file as an argument when double clicked


i have a dostuff.cmd file that takes one argument and looks something like this:

filepath_to_command_to_run %1

If I type dostuff.cmd FILE into the command prompt it runs fine.

Is it even remotely possible to get it so that I can associate that file type with my dostuff.cmd so that if I double click a file the .cmd will get it as an argument? Right now I've associated the file type with it, but when I double click it runs the stuff in the .cmd without getting the file as an argument.


Solution

  • Right click on the file -> Open With -> Choose Default Program -> Browse to and select your cmd file. ( Choose the checkbox saying always use this for this file type if you want)

    Now double clicking the file will open it with the cmd file.

    Alternatively, you can set it directly to filepath_to_command_to_run