views:

384

answers:

1

One of the files in my installation needs to get copied into a location pointed to by a registry key/value pair on the user's destination machine.

Right now, I have a kind of kludgy solution where I have the files set to copy to [TempFolder] in the Components view, and then some custom InstallScript code in my OnFirstUIBefore() function which grabs the value from the registry, then does an MSIGetProperty on [TempFolder] and finally a CopyFile() from [TempFolder] into the path we grabbed from the registry previously.

This works but is all a bit cumbersome. A coworker says that he thinks I SHOULD be able to do an MSISetProperty on a custom property name like MY_RSRC_DIR and then somehow use that custom property in the Components pane to get the file copied to the correct place.

I can get as far as doing the MSISetProperty in an OnBegin() function, but trying to plug that property into the Components view is something I've not been able to get working yet.

Has anyone done this, and if so, how?

+1  A: 

In an InstallScript MSI project, you should take the MSI approach. Create an auxiliary folder (for example adding it to the Files and Folders view), and add your files to it. Make sure to find out its directory property (something like NEWFOLDER1; make sure it's all upper-case). If you want, you can edit the Directory table to make this a child of TARGETDIR, but that's optional and can result in files being placed under [WindowsVolume] if the registry search fails, so it's probably best to leave it as a child of INSTALLDIR.

Then if you can locate the directory before costing (i.e. before CostInitialize, which OnBegin would be), you can set the property (e.g. NEWFOLDER1) with a System Search, SetProperty custom action (type 51), or MsiSetProperty(). If you must find it after costing, you'll need to use either a SetDirectory custom action (type 35), or MsiSetTargetPath(), as the property will no longer update the directory.

This way Windows Installer will track the file location for you and uninstall should work properly.

Michael Urman