cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Pilgrim

Copying a file at runtime from the directory where the .msi is located

I'm working on an install where I need to be able to deliver a unique credentials file for each customer running my install.

My options are:

1) to try to stuff the file into the .msi (replacing a placeholder in it) prior to distributing to each individual customer.

2) supply a file that can be downloaded by the customer along side their .msi file and have this file be copied to the correct location when the .msi is run.

I've opted for option 2 because it seems like it will be much easier to implement and less error prone.

I have added an entry into the MoveFiles table via the direct editor. If I place the source file into a location like C:\Foo and set a property that contains that value, I can supply the property name in the MoveFiles entry and everything works as expected.

What I would ultimately like to do is to use a property that resolves to the location from which the .msi file is being run. For instance, if the .msi is copied to a system's desktop, the property should resolve to that location. If its being run C:\Temp, then the property should resolve to C:\Temp, etc... I cannot figure out if a property exists that will do this for me. I tried using SourceDir but I got an error from Windows Installer.

Does anyone have any insight into how I can do this?

Will this work if the .msi (and credential file) are located on a network share? That is to ask whether or not the value returned will be a unc path that can be used in the MoveFiles table/action.

Thanks,
-Al
Labels (1)
0 Kudos
4 Replies
Highlighted
Pilgrim

Method tip

I have a similar requirement I use in different situations. Only way I was able to do this is via InstallScript custom action using the SETUPEXEDIR property to seed the path to the custom action and doing a CopyFile function.

The downside is that Windows installer won't know about the file and therefore won't uninstall or repair it and I had to create another custom action to deal with it.
0 Kudos
Highlighted
Pilgrim

Re: Copying a file at runtime from the directory where the .msi is located

I read about SourceDir in the help, but when I try to use it, its not working properly... I get an error:

"Error 2706. Source paths not created. No path exists for entry SOURCEDIR in Directory table."

The ResolveSource action is in my Execute Sequence long before the MoveFiles Action.
0 Kudos
Highlighted
Pilgrim

Immediate Execution

Make sure it's set for Immediate Execution rather than deferred. In 'Deferred' properties don't seem to work well.
0 Kudos
Highlighted
Pilgrim

Re: Copying a file at runtime from the directory where the .msi is located

The solution was so simple...

using SOURCEDIR instead of SourceDir in the entry in the MoveFiles table works great.

I have to say... the Help for Windows Installer stinks.
0 Kudos