BackDream
Posts: 2
Joined: Tue Dec 11, 2007 9:21 am

Complex COM object unreg/reg

Hello,

I have a COM object that works in a very unusual way: when you register it into the system (alling its DllRegisterServer) it writes (YES, it writes) a driver into c:\windows\drivers and registers the driver with the system. When you unregister the COM objects, it deletes the driver from the system.

The problem is that deleting the driver needs a reboot.

So, looking to build an upgrade project I should be able to:
1) check if the COM object included in my install package is newer than the one currently installed
2) if so uninstall (DllUnregisterServer) and reboot the computer
3) after reboot, resume setup
4) during setup, register the more recent COM object

But if the COM object version are the same (the user already has latest version) I should avoid all this hassle and upgrade my software without unregistering/rebooting/re-registering.

I struggled a few days with custom actions but... finally I decided to ask. How do I do the above?
THANKS!
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

The only solution for this is to manually edit the MSI file with Orca. Here are the steps:
- in the "Organization" page make sure that the COM is the only resource in it's component
- in the custom actions page create the custom actions that register and unregister the COM
- for the custom actions you use these conditions:
$myCOM.dll=3 (for the register COM custom action)
(($myCOM = 2) AND (?myCOM = 3)) (for the unregister COM custom action)
where "myCOM.dll" is the component of your COM in the "Organization" page
- save and build the project
- open the MSI with Orca and go to the "InstallExecuteSequence" table
- order the actions in the table by their Sequence by clicking on the "Sequence" tab
- create the "InstallExecute" action right before the "InstallFinalize" action (you can set the Sequence of the "InstallExecute" action to the sequence of the "InstallFinalize" action minus 100)
- go to the "RemoveExistingProducts" action and set it's sequence to be between the "InstallExecute" and "InstallFinalize" actions

This way the last three actions are scheduled right after one another: InstallExecute, RemoveExistingProducts, and InstallFinalize.

In this case the updated files are installed first and then the old files are removed. However, if the removal of the old application fails, then the installer rolls back both the removal of the old application and the install of the new application.

You can read about the other available options here:
http://msdn2.microsoft.com/en-us/library/aa371197.aspx
But if the COM object version are the same (the user already has latest version) I should avoid all this hassle and upgrade my software without unregistering/rebooting/re-registering.
Please note that if the COM already exists on the target computer and it has the same version like the one in the MSI package, then the one in the MSI will not be installed.

To see in what cases the file in the MSI will be installed over the file on the target computer please see this page:
http://msdn2.microsoft.com/en-us/library/aa368599.aspx

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”