Pass command line arguments to Windows “Open With”

I have a program that opens with a specific shortcut, but the shortcut seems to send parameters to the application.  If I go directly to the target directory and double-click, it does not work.  However, if I use the command line and pass in a certain argument, the application opens correctly.

I want to open certain file types using the application, but the application must have the parameters, or it will not work.  Is it possible to do this sort of thing?

Solution:

Ran into the same problem as @jtpereyda and the solution from @bobbymcr didn’t work for me either. I was trying to get all the command line parameters passed into node.js scripts without needing node.exe on the command.

The problem is that if you have already associated the program with the extension via the Open With dialog then you will have created an application association, instead of a file extension association, between the two.  And application associations take precedence.

If you don’t mind editing the registry you can modify the (Default) key at the following path:

HKEY_CLASSES_ROOTApplicationsnode.exeshellopencommand

You should replace node.exe with the application you are adjusting.

Or you can just delete the application folder from the HKEY_CLASSES_ROOTApplications folder entirely and your ftype association will start working.

Be sure to use %* which will pass in the remaining unspecified command line arguments or nothing at all.  If you do "%2" "%3" "%4" "%5" you will get 5 empty string params passed into your application when you don’t specify any command line arguments.

Finally, if you are not ok with modifying the registry by hand then you can use a freeware tool from Nirsoft – FileTypesManager – http://www.nirsoft.net/utils/file_types_manager.html

File associations will appear at the top of the list, without any text in the first extension column.  Just find the name of the executable in the list and select it to modify the command line field for the open action name.

On windows7 the changes were reflected immediately without any reboot or application restarts.  However the Nirsoft utility has a feature to “Refresh the Desktop” on any modification, so it leads me to believe that maybe Vista or prior OS versions would cache the data.  In which case the utility would be a better bet, otherwise you might need to log off and log on to see the changes.