DDi
Posts: 17
Joined: Tue Feb 25, 2014 1:22 pm

Despite condition value is added to registry

I have a MSI with a property "A", default value "*". The software is installed via the command line, for example:

msiexec /i test.msi "A=1234" ADDLOCAL=test

This property ("A") is submitted to a merge module property "A" via a custom action (Set Installer Property):

property: A.<GUID of merge module>
Value: A

This merge module writes a value to the registry based on a condition:

A <> "*"

It works fine when installing the software, but when I right click on my msi and choose repair, a "*" is written to the registry despite the condition. This value should not be written to the registry because it is a "*". The value "1234" should remain in the registry.

Advanced Installer version: 11.6.3
Tested on: Windows 8.1

Any help is appreciated.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Despite condition value is added to registry

Hello,

Do you have "Set persistent property" option enabled? With this option, the property will be stored in the registry and available in maintenance mode (repair, uninstall, etc.).

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
DDi
Posts: 17
Joined: Tue Feb 25, 2014 1:22 pm

Re: Despite condition value is added to registry

Hi Mihai,

Thank you for your suggestion. This option was not enabled, but after enabling it, the behaviour remains unchanged. I have disabled the option again and ran the setup again with verbose logging.

(In my 1st post I mentioned the property is named "A" and the value is "1234", but in the real situation the property is named "DDI_DATABASE_CONNECTION_STRING" and the value is an ADO connection string: "Provider=SQLOLEDB.1...")
Below I have put some lines from the verbose log during 1st install: msiexec.exe /i "C:\Temp\DDi.msi" DDI_DATABASE_TYPE="ADO" DDI_DATABASE_CONNECTION_STRING="Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Initial Catalog=3.0.0_Test;Data Source=tstsql" /l*vx "C:\Temp\Instal.log" /quiet

...
MSI (s) (D4:1C) [15:22:13:712]: Command Line: DDI_DATABASE_TYPE=ADO DDI_DATABASE_CONNECTION_STRING=Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Initial Catalog=3.0.0_Test;Data Source=tstsql CURRENTDIRECTORY=C:\Temp CLIENTUILEVEL=3 CLIENTPROCESSID=3616
...
MSI (s) (D4:1C) [15:22:13:727]: PROPERTY CHANGE: Modifying DDI_DATABASE_CONNECTION_STRING property. Its current value is '*'. Its new value: 'Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Initial Catalog=3.0.0_Test;Data Source=tstsql'.
...
MSI (s) (D4:1C) [15:22:36:274]: Doing action: CA_SetDDIDatabaseConnectionStringProperty
Actie gestopt 15:22:36: CA_SetDDIDatabaseTypeProperty. Return value 1.
MSI (s) (D4:1C) [15:22:36:274]: PROPERTY CHANGE: Modifying DDI_DATABASE_CONNECTION_STRING.8641B111_EAF3_48E6_A888_F38704925D23 property. Its current value is '*'. Its new value: 'Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Initial Catalog=3.0.0_Test;Data Source=tstsql'.
Actie gestart 15:22:36: CA_SetDDIDatabaseConnectionStringProperty.
...
Property(S): DDI_DATABASE_CONNECTION_STRING = Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Initial Catalog=3.0.0_Test;Data Source=tstsql
...
Property(S): DDI_DATABASE_CONNECTION_STRING.8641B111_EAF3_48E6_A888_F38704925D23 = Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Initial Catalog=3.0.0_Test;Data Source=tstsql
...

Below some lines from the verbose log during repair: msiexec.exe /f "C:\Temp\DDi.msi" /l*vx "C:\Temp\repair.log" /quiet

...
MSI (s) (D4:70) [15:27:07:106]: Command Line: REINSTALL=ALL REINSTALLMODE=pecms CURRENTDIRECTORY=C:\Temp CLIENTUILEVEL=3 CLIENTPROCESSID=1816
...
Property(S): DDI_DATABASE_CONNECTION_STRING = *
...
Property(S): DDI_DATABASE_CONNECTION_STRING.8641B111_EAF3_48E6_A888_F38704925D23 = *
...

In AI, under Registry I have a value in the Merge Module, that writes the value of the property DDI_DATABASE_CONNECTION_STRING to a registry key. Under Organization the component representing the register value has the following condition: (DDI_DATABASE_TYPE = "ADO") AND (DDI_DATABASE_CONNECTION_STRING <> "*") AND (DDI_DATABASE_CONNECTION_STRING <> "")

If I perform a 1st install without setting properties (msiexec.exe /i "C:\Temp\DDi.msi" /l*vx "C:\Temp\Instal.log" /quiet), the default value * is not written to the registry, which is expected behaviour.

When I perform a 1st install with properties set (DDI_DATABASE_TYPE="ADO" DDI_DATABASE_CONNECTION_STRING="Provider=SQLOLEDB.1 ...") these values are stored to the registry (so far so good). After performing a repair I see that * is written to the registry, which is unexpected.

The strange thing is, when I perform a 1st install without setting properties and then perform a repair, no * is written to the registry.

For me this behaviour does not make any sense.

Do you have any new suggestions?

Thanks in advance.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Despite condition value is added to registry

Hello,

Instead of the A <> "*" condition for the registry, please try:
NOT (Installed AND (NOT REMOVE))
or:
NOT REINSTALL
We'll investigate why "Set persistent property" option doesn't work in your case. Can you please send us your test resources with dependencies so we can see the exact settings?

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
DDi
Posts: 17
Joined: Tue Feb 25, 2014 1:22 pm

Re: Despite condition value is added to registry

Hi Mihai,

To perform additional analysis myself, I have created two very simple test projects from scratch. The problem persists using these test projects, which I have attached:

1. TestPropMergeMod.aip: A Test Merge Module that writes a value to the registry
2. TestDDiProject.aip: A Test Project that sets the MergeMod's property using a "Set Installer Property" custom action.

The problem is reproducable by executing:
msiexec /i TestDDiProject.msi TESTPROP="TestValue" /quiet

Value in HKLM\Software\DDi:
Name: TestKey
Value: TestValue

So far so good. Now right click TestDDiProject.msi and choose "Repair".

Value in HKLM\Software\DDi:
Name: TestKey
Value: *

My expectation is that the value "TestValue" would still be there.

Thanks in advance for investigating.
Attachments
TestDDiProject.aip
TestProject
(11.27 KiB) Downloaded 379 times
TestPropMergeMod.aip
Merge Module
(2.92 KiB) Downloaded 391 times
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Despite condition value is added to registry

Hello,

The "Set persistent property" works if set from the merge module or from the main project.

To have it work in the test projects you attached, you should enable "Set persistent property" for the property in the main project, not the merge module. This is because the custom action executes every time (install, uninstall, maintenance) overriding the property from the merge module.

if you enable "Set persistent property" from the merge module, just delete the custom action and set the property from the command line like this:

Code: Select all

TESTPROP.A56A77C6_7FC4_4CDE_99D9_38664ED0A4FA = "TestValue"
All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
DDi
Posts: 17
Joined: Tue Feb 25, 2014 1:22 pm

Re: Despite condition value is added to registry

Hi Mihai,

Thank you for your reply.

Your suggestion to check "Set persistent property" in the main project, simply restores the value set during install, when performing a repair.

I want the register value to remain unchanged:
1.

Code: Select all

msiexec /i TestDDiProject.msi TESTPROP="TestValue" /quiet
-> Results in register value to be "TestValue"
2. Open Register Editor and change "TestValue" to "TestValue2"
3. Perform repair -> Expectation is that the register value remains "TestValue2". "Set persistent property" resets the value to "TestValue".

Besides I would like the value to be changed to "TestValue3" when I perform:

Code: Select all

msiexec /f TestDDiProject.msi TESTPROP="TestValue3" /quiet
In this case "Set persistent property" still resets the value to "TestValue".

Do you have a suggestion how to achieve the desired behaviour?
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Despite condition value is added to registry

Hi,

Yes I do, you can try using the "Never overwrite" option for its component in the Organization page in this case. Just press F8 while the registry is selected in the Registry page.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
DDi
Posts: 17
Joined: Tue Feb 25, 2014 1:22 pm

Re: Despite condition value is added to registry

Thanks for your reply. Unfortunately your suggestion to check "Never overwrite" does not solve the case with

Code: Select all

msiexec /f TestDDiProject.msi TESTPROP="TestValue3" /quiet
, because when "Never overwrite" is checked, the value is only (over)written during 1st install/upgrade.

I always want the register value to be written (during install and re-install) if the related property is set with a value (except "*"). I want the register value to remain unchanged when the related property is not set (or set with "*").
DDi
Posts: 17
Joined: Tue Feb 25, 2014 1:22 pm

Re: Despite condition value is added to registry

Hi Mihai or anyone else who reads this post,

I am still in need for a solution for a problem which seems quite simple, but apparently appears to be more complex than expected.

I would like a merge module to write a value to the registry if the value is set (using a property value) during install and repair, but leaves the value in the registry unchanged if the property value is not set.

Simply setting a condition (what I expected to be the simplest solution) does not work as expected.

Any help is appreciated.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Despite condition value is added to registry

Hello,

First of all we apologize for such a delayed answer. In order to achieve what you want you should use a bit more tricky workaround.

Here's how Windows Installer works: during installation if a component condition is TRUE, then its state will be set to install and the state will be also preserved during later reinstall operations (e.g. during maintenance mode). Therefore if at first install time your registry component condition is evaluated to TRUE, then during the subsequent repair operations the registry component will always be repaired (even if on maintenance the component condition is evaluated to FALSE). In order to avoid this behavior you should set the "Transitive" flag for your registry component. In this way the component condition will be reevaluated during reinstall mode too.

However, please note that if the component condition will be reevaluated to FALSE during reinstall, then the component will be uninstalled (and the registry value will be removed). Therefore, you need to use another transitive component which will install the registry value only when the related registry already exists and your property is set to its default value (i.e. "*").

Here's a step by step approach:
1. open your merge module .aip and go to "Module Details" page
2. in the "Properties" section add the following property:
  • Name: REG_KEY
    Value: DDi
3. go to "Search" page and add a new search (REG_SEARCH)
4. from its context menu choose "Add Location -> Registry" and configure the registry search like this:
  • Root: HKEY_LOCAL_MACHINE
    Key: Software\DDi
    Name: TestKey
    Type: Retrieve the raw value
5. go to "Registry" page and under "Software" add a new key with the following name: [REG_KEY]
6. under [REG_KEY] key add a new registry value like this:
  • Name: TestKey
    Data: [REG_SEARCH]
7. select the added registry value and from its context menu use "Go to Component" option
8. in the "Condition" field of the selected component use the following expression:

Code: Select all

((TESTPROP = "*") AND REG_SEARCH)
9. check the "Transitive" flag for the above component and for the component of the second TestKey registry value
10. rebuild your projects and test the scenario again

Also, I've attached a sample created with AI 11.6.3 version which implements a similar behavior.
sample.zip
(3.92 KiB) Downloaded 308 times
Let us know if this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
DDi
Posts: 17
Joined: Tue Feb 25, 2014 1:22 pm

Re: Despite condition value is added to registry

Hi Daniel,

Thank you very much for your very clear and detailed explanation.
Today I finally found some time to have a look at your solution. Unfortunately it does not seem to work when I perform a 1st install and then perform a repair with the property set:

Code: Select all

msiexec /f TestDDiProject.msi TESTPROP="TestValue3" /quiet
In this case the current register value remains unchanged.
It looks like the cause of this lies in an unexpected value of the property "TESTPROP" during repair. I would expect it to have the value "TestValue3", but it has the value "*" instead.

Could you have another look at this issue, please?

Thanks in advance.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Despite condition value is added to registry

Hello,

I've tested the scenario and I replicated the behavior. However, after further investigating this it seems this is the normal behavior. When using the /f repair command line the "REINSTALLMODE" property it is set by default with a value of pecms. Also, this option ignores any property values that you type at the command line. Therefore, the "TESTPROP" property will be set to its default value (*) and the "TestKey_1" component will be installed, the one with the following condition:

Code: Select all

((TESTPROP = "*") AND REG_SEARCH)
So, the second component will install the registry with its existing value (fetched during the registry search (REG_SEARCH).

In order to avoid this behavior you should run the repair installation using a command line (including the v switch) like this

Code: Select all

msiexec /fvm TestDDiProject.msi TESTPROP="TestValue3" /quiet
If you have any questions let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
DDi
Posts: 17
Joined: Tue Feb 25, 2014 1:22 pm

Re: Despite condition value is added to registry

Hello Daniel,

This is the desired behavior for us.

Thank you very much.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Despite condition value is added to registry

You're always welcome.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”