Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
Which version of Windows are you using? –  iglvzx Nov 27 '11 at 3:43
    
I am using Windows 7. –  Josh P Nov 28 '11 at 23:44
    
This has better solutions: superuser.com/questions/136133/… –  user309085 Mar 20 at 3:16

4 Answers 4

up vote 8 down vote accepted

Ran into the same problem as @Josh 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_ROOT\Applications\node.exe\shell\open\command

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

Or you can just delete the application folder from the HKEY_CLASSES_ROOT\Applications 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.

share|improve this answer

Here is an extension that seems to do exactly what you want. I've never used it before, but it seems to get good reviews. leave a comment if there are issues.

share|improve this answer

You can do this with assoc and ftype at the command prompt. Open an elevated command prompt and try the following:

ftype MyFileType=C:\MyDir\MyProgram.exe /arg1 /arg2 "%1"
assoc .xyz=MyFileType

This will associate the .xyz extension with MyProgram.exe and will pass the command line /arg1 /arg2 [filename.xyz] to the program to run it.

share|improve this answer
1  
Accepted because this seems to be the right answer from what I have researched. However, this process seems ineffectual on the system I'm using. I can use ftype and assoc to verify that the changes went through, but it does not affect the program used to open files. Maybe the process has changed in Windows 7? –  Josh P Jan 4 '12 at 3:08

The person placing the question reports the Best answer doesn't actually work.

I've figured it out for XP, which might apply to later OS.

At a cmd prompt you need two commands: assoc, ftype.

These two can show what is associated and then edit the association but there is a twist, the MS instructions seem to be wrong/incomplete. I was alerted to this by noticing an undocumented association style by known veteran applications, why?

This example enables many arguments to be passed to the associate program.

ftype name_of_assoc="C\blah\aprog.exe" "%1" "%*"

Not a typo that is "%1" "%*". The percent star will not work without the preceeding percent 1.

And that goes live immediately, no requirement to log out etc.

Done right will pass 3 to arg[]

myfile.wotsit file1 file2 file3

Haven't done it but it looks like the following outside quotes would pass -m if the program needs a flag.

ftype name_of_assoc="C\blah\aprog.exe" -m "%1" "%*"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.