phancox
Posts: 17
Joined: Sat Jun 24, 2006 11:03 am

Moving Existing File or Install if Not Exist

Can someone suggest the "correct" approach for dealing with this situation.

Earlier versions of our installer placed a database file under "C:\Program Files\Company\Product\" which was fine in Windows XP. However, we now install this file into the Common Application Data directory instead. When upgrading an existing installation, we would like to relocate the database file.

The approach we've tried so far is to use a "move/copy" operation as well as a standard install of the default database so that it will be used if there isn't a copy in "C:\Program Files\Company\Product\". The component is set to "Never Overwrite" and "Permanent". Unfortunately the logs indicate that the move occurs first, but the installation of the default database sees the moved file as unversioned and is then copied over it. My understanding is that the reason the "Never Overwrite" is not working is that the "move/copy" resource is not the key member of the component but I can't find a way to make it the key member (option is always disabled). And I don't think I can put the "move/copy" resource into its own component.

Although we've been using Advanced installer for many years, it's only been for a single product and this is the first time we've attempted to do anything above the basic level. Hope someone can advise a standard way of handling this or point me in the right direction.

Thanks in advance.
Bogdan
Posts: 2794
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Moving Existing File or Install if Not Exist

Hi,

The solution is much simpler, what you need to do is to have a solid condition on the default database installation, which I assume you handle using our SQL Scripts page support.

What you need to do is set the "Scripts Condition" field to "NOT OLDPRODUCTS", so the script will run and create the default DB only if the package is installed for the first time on the machine.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
phancox
Posts: 17
Joined: Sat Jun 24, 2006 11:03 am

Re: Moving Existing File or Install if Not Exist

Not sure whether this helps me?

We aren't using the SQL Scripts page. It's a Microsoft Access database i.e., a single ".mdb" file which has been pre-built with default tables etc during the build process. We just install it the same as any other file. For my purposes you can ignore the fact that it has anything to do with a database.

The problem we're trying to resolve is in the case of a previous install where the "live" database is in the wrong location, we want to move it to the correct location. This is the same place as the installer will install the ".mdb" file for a new install.

What's happening at the moment is the file is being moved but then overwritten by the default one from the installation package.

REGARDS
Peter
Bogdan
Posts: 2794
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Moving Existing File or Install if Not Exist

Hi Peter,

The same condition I mentioned can be used to decide if the default DB file will be installed too. All you need to do is to locate its component, press F8 while the file is selected.

Once Advanced Installer has taken you to its component set the condition field to NOT OLDPRODUCTS, this will make the file to be installed only if its not an upgrade, thus avoid overwriting the copied one.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
phancox
Posts: 17
Joined: Sat Jun 24, 2006 11:03 am

Re: Moving Existing File or Install if Not Exist

Don't think that will handle some of the more obscure use cases. e.g., user uninstalls previous version first. Although this will leave the MDB file, the install of new version will then overwrite it as it currently does.

Solution I'm currently pursuing is to run a search for the file and set the EXISTINGMDB property. However, I don't think I'm setting the correct condition on the component that copies the new MDB file? I'm testing "NOT EXISTINGMDB" but not sure whether the property is a boolean or the location of the file that the search found. Log shows the search running but interpreting the log I'm not sure if the file was found?

Code: Select all

AppSearch: Property: EXISTINGMDB, Signature: FileSearchSign
MSI (c) (80:9C) [19:41:49:927]: Note: 1: 2262 2: CompLocator 3: -2147287038 
MSI (c) (80:9C) [19:41:49:927]: Note: 1: 2262 2: IniLocator 3: -2147287038 
MSI (c) (80:9C) [19:41:49:927]: Note: 1: 1322 2:  
MSI (c) (80:9C) [19:41:49:927]: Note: 1: 1322 2:  
MSI (c) (80:9C) [19:41:49:927]: Note: 1: 1325 2: database.mdb 
Action ended 19:41:49: AppSearch. Return value 1.
MSI (c) (80:9C) [19:41:49:927]: Doing action: AI_AppSearchEx
Is this indicating that the file was found?

What's the correct way to test the property set by the search?

It looks as if the search is run before testing the condition (which is what I need), is this correct?

REGARDS
Peter
phancox
Posts: 17
Joined: Sat Jun 24, 2006 11:03 am

Re: Moving Existing File or Install if Not Exist

Sorted it out.

The log is in fact indicating that the file wasn't found. Needed to do some experimentation to find what was "normal".

The file wasn't found because "[APPDIR]" was specified as the location to search. This was the correct location but I'm guessing that it wasn't defined at the point the search was run. Changing the search location to be "[ProgramFilesFolder]" fixed that.

Once that was fixed, specifing "NOT EXISTINGMDB" as a condition on the component that copied the default database worked.

REGARDS

Return to “Building Installers”