How to set file associations for portable program?

pstein

Extraordinary Member
Assume I run a program from USB flash drive or network drive.
It is not installed on the local Win 7 computer but it works.

Hence when I go to menu

START--->Control Panel--->Programs--->Default programs

this program is NOT listed there as a possible application.
So it cannot be defined as a default program for selected file associations.

How can I associate some file extensions to such a program anyway?

I guess I have to declare this program as a valid target for file associations. How does that work (without full (re)installation)?
 


BurrWalnut

Extraordinary Member
To do it manually, you would use the assoc command to associate extensions to file types and the ftype command to associate a file type with an application. For example, if you had an extension named .ldg that was used by a program named ledger.exe, you would create a file type called, say, myaccs. To run the commands open a Run window (Windows Logo key+R), type cmd and press Enter. The manual assoc and ftype commands would be:

assoc .ldg=myaccs (make sure you use a unique name for filetype, otherwise chaos will prevail, check the registry if in doubt)
assoc .acc=myaccs (i.e. more than one extension can be associated to a file type)
ftype myaccs= %SystemRoot%\Program Files\ledger.exe %1(this is the location of the program)

Now, when you double-click on a file with the extension .ldg or .acc, Windows will recognize it and launch ledger.exe.

An easier to understand example of the above is a .txt file, which we all use in Notepad:
Typing assoc .txt will return txtfile (the file type)
Typing ftype txtfile will return %SystemRoot%\System32\notepad.exe %1 (the full path of the program and %1 representing a passed parameter)
Alternatively, look in the registry hive HKEY_CLASSES_ROOT for .txt and further down for txtfile.
 


Last edited:
This website is not affiliated, owned, or endorsed by Microsoft Corporation. It is a member of the Microsoft Partner Program.
Top