InstallShield 2016
Project • This information applies to InstallScript projects.
You may want your installation to launch a SQL script only if certain conditions are met on the target system.
InstallShield generates a set of default global event handlers, each of which is a function scripted in the InstallScript language. The following SQL-related events are automatically called by the InstallShield framework:
• | OnSQLServerInitialize |
• | OnSQLComponentInstalled |
OnSQLServerInitialize is called by OnFirstUIBefore, and OnSQLComponentInstalled is called during file transfer, for each component installed.
Note • If you are working on a script that had overridden OnFirstUIBefore before upgrading to InstallShield and it is not calling OnSQLServerInitialize, you should add that code to your script file.
In your script, you can modify OnSQLServerInitialize and OnSQLComponentInstalled to perform checks for different things. For example, you can check for a user with administrator rights in the sample code below.
function OnSQLComponentInstalled(szComponent)
string sMessage;
string sData;
number nResult;
begin
if( Is( USER_ADMINISTRATOR, sData ) ) then
nResult = SQLRTComponentInstall( szComponent );
if( nResult = SQL_ERROR_ABORT ) then
sMessage = SdLoadString( IDS_IFX_SQL_ERROR_RUN_FAILED );
MessageBox( sMessage, MB_OK );
abort;
endif;
else
//User does not have administrator rights, so we do not run scripts
endif;
end;
Note • You can configure the behavior for script failure in the InstallShield interface when you click a SQL script in the SQL Scripts explorer, and then go to the Runtime tab. The Script Error Handling section lets you select one of the following options:
• | On Error, Go to Next Script |
• | On Error, Go to Next Statement |
• | On Error, Abort Installation |
See Also
InstallShield 2016 Help LibraryAugust 2016 |
Copyright Information | Flexera Software |