aps_brar
Posts: 8
Joined: Wed Jul 29, 2009 6:42 am

Conditional Install

we already have a product that has been installed on customers machines with AI, now we are going to release another product that needs to be installed in the same folder as existing product and it should only be installed if the file version of the already installed product's main exe is same as the main exe of new product which is to be installed. (mind you these are totally different products not an upgrade)
So i was thinking i can use custom launch condition to achieve this but i have a few issues here

1. The existing product on users machine could have been installed anywhere as we let them choose their location from the customize dialog so i can not use search here. Is there a way i can ask the user to select the folder where previous product is installed or does AI leave any info on the machine (like registry etc.) from where i can figure out the previous product's install location?

2. Even when i find out the location of previous products I still need to compare the file versions of the main exes, one that is already installed and the other that is in the package that is going to be installed. so i thought i could use vbscript to do this by querying the msi database by using the following code
Set xInst = CreateObject("WindowsInstaller.Installer")
Set xDB = xInst.OpenDatabase("D:\New Folder\My.msi", 1)
Set xView = xDB.OpenView("SELECT Version FROM File WHERE File = 'My.exe'")
Call xView.Execute
Set record = xView.Fetch

If NOT record Is Nothing Then
MsgBox record.StringData(1)
End If

Set xView = Nothing
Set xDB = Nothing
Set xInst = Nothing

But i dont know how will I pass in the path to the msi from within the installer.

Can somebody please help? I am going in the right direction or have i made it all too difficult for myself and there is an easier way to do this.
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Conditional Install

Hi,
Is there a way i can ask the user to select the folder where previous product is installed
Here is a How To that can help you.
does AI leave any info on the machine (like registry etc.)
No, AI doesn't leave any info, but you can set this info if you wish from the Registry page.
But i dont know how will I pass in the path to the msi from within the installer.
The property called "OriginalDatabase" is set to the path of the current installation package.To pass the value of a property, let assume OriginalDatabase, you can use this syntax in VBscript:

Code: Select all

Session.Property(“OriginalDatabase”)
So,instead of :

Code: Select all

 Set xDB = xInst.OpenDatabase("D:\New Folder\My.msi", 1) 
You will have :

Code: Select all

 Set xDB = xInst.OpenDatabase(Session.Property(“OriginalDatabase”), 1) 
Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”