0
votes

I have build an installer using installshield 2016.

I have a VB script (running in a custom action) that checks if a database is empty and when it is, the uninstall can take places.

The settings of the custom action are:

  • Return Processing: Synchronous (check exit code)
  • In-script Execution:Immediate Execution
  • Execution Scheduling: Always execute
  • Install Exec Sequence: After InstallValidate
  • Install Exec Condition: REMOVE="ALL"

The custom action with the script runs and the Message box is shown but the installer ignores the Exitcode = 3.

The VB script:

Function CheckService()
    On Error Resume Next

    Set objConnection = CreateObject("ADODB.Connection")
    DB_CONNECT_STRING = "Provider=SQLOLEDB.1;Data Source=localhost;Trusted_Connection=Yes;"

    objConnection.Open DB_CONNECT_STRING

    set rs = objConnection.Execute("SELECT COUNT(*) as cnt FROM master.dbo.sysdatabases WHERE name = 'MonitoringConfiguration'")

    if not rs.EOF then
      recordsCount = cint(rs("cnt"))
    end if

    objConnection.Close

    if recordsCount = 0 then
        CheckService = 1
        Exit Function
    end if

    DB_CONNECT_STRING = "Provider=SQLOLEDB.1;Data Source=localhost;Initial Catalog=MonitoringConfiguration;Trusted_Connection=Yes;"

    objConnection.Open DB_CONNECT_STRING

    set rs = objConnection.Execute("SELECT COUNT(*) as cnt from ServerSettings")

    if not rs.EOF then
      recordsCount = cint(rs("cnt"))
    end if

    objConnection.Close

    if recordsCount <> 0 then
        x=MsgBox("There are still monitoring services deployed. Please remove them first before remvoing System Monitoring",0,"Unable to Uninstall application")
        CheckService = 3
        Exit Function
    else
        CheckService = 1
        Exit Function
    end if

End Function

Thank you in advance.

1
You did not mention your Ignore Error Code selection. So it is probably wrong. - Hans Passant
This option is in the "Return Processing" normally. Now it is set to "Synchronous (Check exit code). The other option is "Synchronous (Ignores Exit Code). - Pol De Smet

1 Answers

0
votes

you need to select the action type Stored in Binary Table

that way you'll be able to force the execution of a single function rather than the entire script.