bhodso
Posts: 19
Joined: Sun Apr 20, 2008 1:11 am

Copy file from previous install in upgraded installer

I have an existing installer that installs a text file at a specific location. This file contains user settings. I have authored an upgraded installer for this initial installer. The problem is that the file gets uninstalled when I run the upgrading installer.

I wrote a simple VBSCript that runs in the:

InstallUISequence -> Begin as an attached event.

The problem is that it doesn't seem to ever run. I put in some message boxes to show and they are never shown. Also, it appears that this event even runs after the older installer is already uninstalled (thus deleting the file I need to keep).

Here is my vbscript:

Function CopySettings()
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

Dim pathToAppFolder
pathToAppFolder = Session.property("AppDataFolder")
' MsgBox pathToAppFolder

Dim pathToMyApplicationFolder
pathToMyApplicationFolder = pathToAppFolder & "MyApplication\"
' MsgBox pathToMyApplicationFolder

' copy old settings if there is one during upgrade
Dim pathToSettingsFile
pathToSettingsFile = pathToMyApplicationFolder & "app.sharedsettings"
Dim pathToCopySettingsFile
pathToCopySettingsFile = pathToMyApplicationFolder & "app.sharedsettings.old"
If fso.FileExists(pathToSettingsFile) Then
MsgBox "found existing settings"

fso.CopyFile pathToSettingsFile, pathToCopySettingsFile
Else
MsgBox "shared settings file not found"
End If

MsgBox pathToSettingsFile
MsgBox pathToCopySettingsFile
End Function

Where should I put my script to ensure that is run correctly BEFORE the old installer is uninstalled?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Copy file from previous install in upgraded installer

Hi,

In order to have access to the folders on the disk a custom action must be scheduled after the "CostFinalize" standard action. Note that we have the Preserve File on Install how to which explains an approach for what you need.

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

Return to “Common Problems”