Ok, I'm at my wits end trying to figure this out. I've googled this problem for 2 days and couldn't find anything that worked.

Anyone have a command line or script that will associate programs to a file type? I've tried the assoc command line and another hkcu script that didn't work.



Any help would be greatly appreciated.
Answer Summary:
Start at [TargetHive]\Software\Classes, where you make an entry of '.[ext]' with a 'Default' value of some name, e.g. MyNewExt. Now you need another entry, at the same level, with the same name, in this case 'MyNewExt'. [TargetHive] is HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE, depending on whether you want a user-specific or machine-wide definition. Next, you need a tree structure HKEY_CURRENT_USER\Software\Classes\MyNewExt\shell\open\command, whose 'Default' value points to the executable which will load the .ext file, together with the parameter '%1'. You can do this in batch (using REG.EXE) but I would imagine most people would use VBS or, nowadays,PowerShell. There are LOADS of sample registry scripts available.
Cancel
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

1
File associations are set in the registry.

Start at [TargetHive]\Software\Classes, where you make an entry of '.[ext]' with a 'Default' value of some name, e.g. MyNewExt. Now you need another entry, at the same level, with the same name, in this case 'MyNewExt'. [TargetHive] is HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE, depending on whether you want a user-specific or machine-wide definition.

Next, you need a tree structure HKEY_CURRENT_USER\Software\Classes\MyNewExt\shell\open\command, whose 'Default' value points to the executable which will load the .ext file, together with the parameter '%1'.

You can do this in batch (using REG.EXE) but I would imagine most people would use VBS or, nowadays,PowerShell. There are LOADS of sample registry scripts available.
Answered 03/06/2012 by: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity