This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- InstallScript Upgrade to run sql scripts
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
‎Jun 10, 2008
05:06 PM
InstallScript Upgrade to run sql scripts
I am trying to find a way to tell if the installation is performing an upgrade. I need to have the the isntallation run through a couple of dialogs when it is doing upgrades to install sql scripts. I use all installscript to run my sql scripts, but I have upgrades that require files to be replaced and for a sql script to be ran. I do not want the user to have to uninstall so I want to detect that it is an upgrade and display the dialogs I used for the new install to open up and get the information so I can then run the sql scripts.
(10) Replies
‎Jun 10, 2008
06:16 PM
Assuming an InstallScript project, perhaps see if UPDATEMODE detects what you want? The OnSetUpdateMode event handler shows how it's used.
‎Jun 11, 2008
08:59 AM
Yes, it is a pure InstallScript project not much info. Is this a true or false response like
Where should I test for this maybe in the onbegin() and if it is true have it call my own MY_onFirstUIUpdate() function to run the dialogs again?
function onBegin()
if(UPDATEMODE = TRUE) then
MyUpdateTasks();
endif;
Where should I test for this maybe in the onbegin() and if it is true have it call my own MY_onFirstUIUpdate() function to run the dialogs again?
‎Jun 11, 2008
09:35 AM
Hello,
You mentioned that you don't want your product to go into uninstalling the product or maintenance mode. My question to you is, Are you changing the Product Version number? If you change the Product Version number, the installation should go into these sequence of events:
OnBegin
OnUpdateUIBefore
// Copy Phase (Upgrade/Patch)...
OnUpdateUIAfter
OnEnd
For us, our current version plan is this.
Major.Minor.Patch.Build
We usually keep Major and Minor numbers the same until we decide we are going to come up with a new release. Which also means that if these two sets of numbers change, then I put the installation into upgrade mode which I write my code accordingly. The patch should be self explanatory. The build is the product build number that is associated to our automated build process. The build number is ever increasing number and is unique. It identifies the file set that is in the installation. So when we work on releasing a patch, we know what file set it is. If there is a problem with the file set, we recompile the product which will automatically increase the build number, but it doesn't increment the patch number. It hasn't been release it yet. When it is released, then we increment it and say that we are ready to work on the next patch. This number is really only used for our company internal use.
The reason why I mention patches is simple. Anytime that Install Shield sees an updated Product version to what is currently installed on the system, it will go into the OnUpdateUI events. So you need to write your scripts according to if it is a patch or upgrade.
You mentioned that you don't want your product to go into uninstalling the product or maintenance mode. My question to you is, Are you changing the Product Version number? If you change the Product Version number, the installation should go into these sequence of events:
OnBegin
OnUpdateUIBefore
// Copy Phase (Upgrade/Patch)...
OnUpdateUIAfter
OnEnd
For us, our current version plan is this.
Major.Minor.Patch.Build
We usually keep Major and Minor numbers the same until we decide we are going to come up with a new release. Which also means that if these two sets of numbers change, then I put the installation into upgrade mode which I write my code accordingly. The patch should be self explanatory. The build is the product build number that is associated to our automated build process. The build number is ever increasing number and is unique. It identifies the file set that is in the installation. So when we work on releasing a patch, we know what file set it is. If there is a problem with the file set, we recompile the product which will automatically increase the build number, but it doesn't increment the patch number. It hasn't been release it yet. When it is released, then we increment it and say that we are ready to work on the next patch. This number is really only used for our company internal use.
The reason why I mention patches is simple. Anytime that Install Shield sees an updated Product version to what is currently installed on the system, it will go into the OnUpdateUI events. So you need to write your scripts according to if it is a patch or upgrade.
‎Jun 11, 2008
11:43 AM
Yes, we are changing the product version like you mentioned you were. Our patches though can consist of SQL Script updates that need to be applied. My current project has these in the Support Files and has to run a script to retrive config information from the users databases this is how I build the sql connections. So I need to make sure if they installed the DB feature it runs the sql functions on an upgrade this is where I have the initial install for the sql scripts My_FeatureInstalled() calls My_SQLProcess().
‎Jun 11, 2008
12:56 PM
If you are looking for a mechanism to find out if they have installed the database feature on the machine or not, try putting this in the OnUpdateUIBefore event. This snip it piece of code will loop through the installed features that could be installed on the machine and will set a nvSelected if that feature was installed on the target machine.
Is this what you need?
MediaGetData( MEDIA, MEDIA_FIELD_MEDIA_FLAGS, nMediaFlags, szIgnore );
FeatureListItems(MEDIA, "", listCompList);
nResult = ListGetFirstString( listCompList, szComponent );
while ( nResult != END_OF_LIST )
nResult = FeatureGetData(MEDIA, szComponent, FEATURE_FIELD_SELECTED, nvSelected, svNULL);
nResult = FeatureGetData(MEDIA, szComponent, FEATURE_FIELD_DISPLAYNAME, nvNULL, strDisplay);
if ( (nvSelected = TRUE) && ( strDisplay != "" ) ) then
if strDisplay = "My Component 1" then m_bCommpent1_Enabled = TRUE;
elseif strDisplay = "My Component 2" then m_bCommpent2_Enabled = TRUE;
elseif strDisplay = "My Component 3" then m_bCommpent3_Enabled = TRUE;
elseif strDisplay = "My Component 4" then m_bCommpent4_Enabled = TRUE;
elseif strDisplay = "Database" then m_bDatabase_Enabled = TRUE;
elseif strDisplay = "Web Site" then m_bWebSite_Enabled = TRUE;
endif;
endif;
nResult = ListGetNextString (listCompList, szComponent);
endwhile;
Is this what you need?
‎Jun 11, 2008
01:45 PM
Thank you that covered my next question, but I guess I need to know if on an update it will run the functions for a feature - feature_Installed() and feature_installing(). THis is where i Have some of my code, if it does not run these I will need to modify the install portion and then add this code to the upgrade section as well.
‎Jun 11, 2008
02:16 PM
What I do is use global boolean flags for upgrade, patches, and individual features. Then I set the flags in the OnUpdateUIBefore event based on what is installed and the product version. Let the installation/upgrade/patch put the files into place. Then I configure the system in the OnUpdateUIAfter events. That way, all the files should be in place for you to update the configuration of the product and update the database.
This works for us very well. Feel free to adopt this method if it works for you.
This works for us very well. Feel free to adopt this method if it works for you.
‎Jun 11, 2008
03:20 PM
So if I set global variables in the initial install it keeps these for later use?
‎Jun 11, 2008
04:15 PM
Unfortunately, No... However, you can set them based on what is installed...
To set the features global variables flags, use the sample code I posted in this thread to set them.
To see if this is a patch or upgrade, use the product version to determine that. You have access to the previous version and the version you are about to install.
To set the features global variables flags, use the sample code I posted in this thread to set them.
To see if this is a patch or upgrade, use the product version to determine that. You have access to the previous version and the version you are about to install.
// This will get the product version of what is currently installed.
strRegPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"+ PRODUCT_GUID;
My_GetRegistryEntry(strRegPath, "DisplayVersion", strInstalledVersion, strError);
// IFX_PRODUCT_VERSION is the product version that is about to be installed.
Product Version := IFX_PRODUCT_VERSION
‎Jun 11, 2008
04:41 PM
Thank you for your help, I have this almost done. thanks again