davidmckinley
Posts: 4
Joined: Tue Sep 05, 2006 3:16 pm

Force registry update and service restarts on modify

Using enterprise installer, I have setup up a couple of registry entries that can be customized during an install. These registry entries are read by a Windows Service program that also gets installed. I do the customization on a custom dialog that can be invoked by a new button on the "CustomizeDlg" dialog.

It all works find on a new install. The problem is if the installer is run again for maintenance. If the user clicks 'Modify' on the "MaintenanceTypeDlg" screen, they can then go to the custom dialog and change the values for the registry entries.

But, the new values do not get written when the Maintenance is completed. What I need is a way to force the associated registry entries to be rewritten, and the service that uses them to be restarted.

Is there a way to do that?
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,

This is related to the windows installer behavior. Windows installer does not detect that something is changed in the "CustomizeDlg" dialog (no feature state changes) and because of this your registry value is not updated.

You need to force the reinstallation of the feature that contains that registry value.
To do this you need to manipulate the "REINSTALL" property like this:
Create a "Script In Line" cuatom action under "InstallExecutesequence->Begin" standard action. Use this code:

Code: Select all

Session.Property("REINSTALL") = "MainFeature"
Where the MainFeature is the feature that contains the registry value.
Use (Installed) as condition for the custom action.

Regards,
Gigi
_______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
davidmckinley
Posts: 4
Joined: Tue Sep 05, 2006 3:16 pm

Results in error

Gigi,

Maybe I don't understand your instructions.

I've tried putting in the custom action you describe. But, it always causes an error when it is executed. Here are the details on what I did:

I put the service and registry values that need to be reinstalled on modify actions in a separate "Feature" called "Bridgeip". On the definition of that new feature, I selected Display="Not Displayed", Install Level="1", and clicked "Follow Parent", "Disallow Advertise", and "UI Disallow Absent". Before putting in any custom action, I tested the install and remove with this organization setup, and it all seemed to work fine.

Then, on the "Custom Actions" screen, I highlighted "InstallExecuteSequence", clicked on the "ShowStandardAction" tool and selected "Begin" so that "Begin" would be included as an option I could add actions to.

Then, I highlighted "Begin", clicked on the "NewCustomAction" tool, and selected "Script Inline". This showed the "Custom Action Properties" page.

On this page, "Scource Type:" was set to "Visual basic script (*.vbs)". I left this alone.

It wasn't clear whether the "Session.Property("REINSTALL") = "Bridgeip" statement should go in the "Script Text:" box or in the "Action Data:" box, but I've tried them both with similar results.

I also clicked on the "..." box on the "Execution Condition" box, and typed in "(Installed)" for the "Expression", clicked on "Validate" and saw that it validated properly, then clicked on "OK".

I then built the bootstrap .exe file, and ran it to install the product; then again to try to modify or remove the product. Install went fine, but modify and remove both generated errors and aborted.

Since I could not remove the product, I downloaded and ran the "Windows Installer Clean Up" utility from Microsoft, then manually removed all files, services, and registry entries to get the product uninstalled.

With the script statement in the "Script Text" box or the "Action Data" box, the results are essentially the same. Install works fine, but Modify or Remove fails. The only difference is what it says in the error message that is displayed.

When I put the script statement in the "Script Text" box, the error message says: "The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2711."

When I put the the script statement in the "Action Data" box, the error message says: "There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor."

Any ideas ?

Thanks,

David
davidmckinley
Posts: 4
Joined: Tue Sep 05, 2006 3:16 pm

More problems . . .

I've made some progress. Using orca I've discovered that the 'real' name of the feature I put the service and registry entries into is not the name I assign, i.e., "Bridgeip", but rather it is "Feature_5". If there was any way to discover this without analyzing the .msi file with orca, I haven't found it.

By making the custom action say: Session.Property("REINSTALL") = "Feature_5", I can avoid the error message.

But, things still don't work as I need them to. When doing a "Modify" action, rather than just updating the registry and restarting the service, it seems that it tries to completely reinstall the service - and, because it is already running, this triggers the Installer to request a system reboot.

More troubling, when trying to remove the product, it now does not remove this particular service. The only way to get rid of it seems that I have found is to use the Windows Installer Clean-up utility and to manually remove the files and registry entries.

I strongly suspect this can still be handled by the proper custom actions and conditions being set, but with the documentation available with Advanced Installer, I have not been able to figure out how to do it. Any further help you could provide would be greatly appreciated. Without more help, I'm probably going to have to find some other solution for installing my application. That's unfortunate, because I really like your product - but, I can't use it because of the lack of documentation.
Mihai
Posts: 38
Joined: Wed Mar 23, 2005 12:19 pm

Hi,
I've made some progress. Using orca I've discovered that the 'real' name of the feature I put the service and registry entries into is not the name I assign, i.e., "Bridgeip", but rather it is "Feature_5". If there was any way to discover this without analyzing the .msi file with orca, I haven't found it.
You are right, the feature ID is not exposed directly but you can see it, by example, in Custom Action Condition Editor. When the Feature State/Action buttons are pressed a feature picker appears. After a feature is selected, in the Expression filed of the Condition Editor it can be observed the feature ID preceded by a "&" or "!".

By making the custom action say: Session.Property("REINSTALL") = "Feature_5", I can avoid the error message.

But, things still don't work as I need them to. When doing a "Modify" action, rather than just updating the registry and restarting the service, it seems that it tries to completely reinstall the service - and, because it is already running, this triggers the Installer to request a system reboot.
That may happen because the regs are not alone in their component and feature. You must place only the regs component in Feature_5. To restart the service you must use a control operation attached to the reg's component to stop the service and to start it again.


More troubling, when trying to remove the product, it now does not remove this particular service. The only way to get rid of it seems that I have found is to use the Windows Installer Clean-up utility and to manually remove the files and registry entries.
That may appear if your custom action ( Session.Property("REINSTALL") = "Feature_5") runs also on uninstall. That custom action must run only from the CustomizeDlg when the user chooses to change the settings.


The AdvancedInstaller's documentation refers mostly on how to use it and very little on the installation process because this is the Windows Installer tehnology and it would duplicate the Microsoft's documentation.

That is why it is recommended to take a look also on Windows Installer documentation:
http://msdn.microsoft.com/library/defau ... _guide.asp

Hope that helps and let me know if you have any other questions.

All the best,

Mihai
Mihai Udrea
Advenced Installer Team
davidmckinley
Posts: 4
Joined: Tue Sep 05, 2006 3:16 pm

Many Thanks

Mihai & Gigi -

Things are making more sense and working better.

I was not able to make it work by attaching the custom action to the Customize dialog box, though. For some reason, when setting it up that way, the registry values would not get re-written when they change.

But, I put the action on the InstallExecuteSequence->Begin step, as Gigi suggested, and conditioned it using propereties set on the configuration page, so that it only runs if the user has made changes. This seems to work well - it keeps the action from running on uninstall operations.

Thanks for the help!

David

Return to “Common Problems”