views:

350

answers:

2

I'm looking for a way to programatically tweak the particulars of a file association on a Windows system. For example, the "Application User to Perform this Action" setting for the "Open" action for a particular file type.

Clearly I could do this by modifying the registry directly, but if there is an API I'd prefer to use that as it would likely be more resilient to changes in the OS handling of mapping extensions to applications.

For my purposes I'm needing to write this in VBScript (.VBS) file because it is part of a package to be used with VMWare ThinApp that mandates it. However, I'll port/wrap/whatever I need to make this week, so I am open to any solution (including using the .NET framework)

A: 

Have a look at this answer: http://stackoverflow.com/questions/590892/windows-registry-file-association-menu

The file associations are in the registry.

Mark Redman
From the original question "Clearly I could do this by modifying the registry directly, but if there is an API I'd prefer to use that as it would likely be more resilient to changes in the OS handling of mapping extensions to applications."
JohnFx
+2  A: 

Microsoft documents that the official procedure for creating file associations is through modification of the registry. The only other API you need to call is SHChangeNotify, with SHCNE_ASSOCCHANGE, to tell running applications that associations have changed.

Martin v. Löwis