views:

480

answers:

2

I'm writing a basic MSI installer using installshield 2010. A different company would supply a .reg file that the installer would read in runtime and would update the registry accordingly.

I can't figure out how to accomplish this.

I manged to write a script using the Installscript that accomplish this, but when this script is running in Differed execution, I don't know how to get to the source directory where the setup.exe lays (and the .reg file).

MSIGetproperty doesn't work and all I get for SETUPEXEDIR is "".

+2  A: 

During deferred execution you don't have access to most properties. You can either: 1. Use the CustomActionData property to pass the value you need. 2. Use an immediate custom action that updates the registry table with what it reads from the REG file. This way the Windows Installer engine will take care of rollback for you.

I can also suggest an alternative solution: The other company will supply an MST file with the registry table containing what was supposed to be in the REG file. The installation will then be performed with the TRANSFORMS property pointing at the MST. This way you get rollback and uninstall for free.

On Freund
1. I couldn't get the CustomActionData property. I always get ""2. I tried using an immediate custom action, and it does work.The problem is that it doesn't rollback.Regrading the MST, I can't ask the company to do so. So this is not an option for me.
Eldad
1. Are you using CustomActionData properly? (See http://msdn.microsoft.com/en-us/library/aa370543%28VS.85%29.aspx).2. If the immediate custom action does nothing more than update the registry table, rollback will be taken care of for you.
On Freund
1. I followed these instructions:http://kb.flexerasoftware.com/selfservice/viewContent.do?externalID=Q112615but I'm still getting empty strings.2. I understand what you're suggesting and I believe it would work. A question: The .reg file is optional. In case no .reg file is given, I don't want to change the registry. How can I achieve it?
Eldad
You just need an if statement in your immediate CA.
On Freund
I'm guessing we're not on the same page. What I understood was:1. Set the Installer to update registry values to a certain PROPERTY.2. Read the .reg file and set the PROPERTY accordingly.3. The installer will set the registry according to the PROPERTY.How can I insert an if statement to avoid updating the registry if no .reg file is located?
Eldad
The relevant rows would belong to a component whose install condition can be manipulated by the custom action (pay extra care to the sequencing to make sure the action executes before component conditions are evaluated)
On Freund
I'm sorry, but I'm not following you. Can you explain in detail what I should do?
Eldad
As you mentioned, add rows to the Registry table, with the value set to a property, and set the _component field to a new component you create. Give the component a condition that depends on a different property and set value of that property from your custom action to control whether the component (and thus all of the relevant rows in the registry table) is installed or not.
On Freund
A new problem: The component conditions are evaluated before my custom action is invoked.
Eldad
That's why I wrote "pay extra care to the sequencing to make sure the action executes before component conditions are evaluated"
On Freund
Thanks! That did the trick!
Eldad
+1  A: 

You can use the Signature, DrLocator and AppSearch tables together to put the location of the registry file in some public property. We'll call it "MY_REG_FILE". Then you set the condition on your custom action to "MY_REG_FILE". If the file isn't actually there, then the property won't be set, the condition will evaluate to false, and the action won't run.

MSDN has an example of using the three tables together to find a file - http://msdn.microsoft.com/en-us/library/aa371552%28VS.85%29.aspx

Ed
Thanks. I already went with Freund's advice, but your solution looks interesting and easy.
Eldad