cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
benmarty
Level 3

Instance-specific install/un-install of service

I figured out how to prompt for a service instance name and install an instance-specific service name, similar to what SQL Server does by appending "$" and the instance name. I stored the instance name in a property called IS_SQLSERVER_SVCINSTANCE as "$MyInstance", for example. Then I made sure the service name in the tree view included [IS_SQLSERVER_SVCINSTANCE]. Indeed the service got installed with the internal name MyService$MyInstance and even had a dependency on MSSQL$MyInstance set up properly.

The problem is, when I un-install, the service doesn't go away despite the fact that I have configured it to be deleted on un-install. Did it forget the value of IS_SQLSERVER_SVCINSTANCE? Do I need to prompt for it again? Can I force it to be remembered? I thought the un-install info kept some of that kind of information around.
Labels (1)
0 Kudos
(2) Replies
benmarty
Level 3

I worked out that I can use code like this in a VBScript custom action to re-establish the values of my properties on subsequent runs of the installer (works great when running a new install on a system where the service is already installed):
Dim regIndex
regIndex = -1
Do
Dim name
name = Session.Installer.RegistryValue(2, "SYSTEM\CurrentControlSet\services", regIndex)
If IsNull(name) Then Exit Do
If IsEmpty(name) Then Exit Do
If Len(name) = 0 Then Exit Do
If Len(name) >= 9 And Left(name, 9) = "MyService" Then
Dim instance
instance = Mid(name, 10)
Session.Property("IS_SQLSERVER_SVCINSTANCE") = instance
If Len(instance) > 0 Then
instance = Mid(instance, 2)
End If
Session.Property("IS_SQLSERVER_INSTANCE") = instance
If Len(instance) > 0 Then
Session.Property("IS_SQLSERVER_SQLDEP") = "MSSQL$" & instance
Session.Property("IS_SQLSERVER_INSTANCETITLE") = " (" & instance & ")"
Session.Property("IS_SQLSERVER_SERVER") = "(local)\" & instance
Else
Session.Property("IS_SQLSERVER_SQLDEP") = "MSSQLSERVER"
End If
Exit Do
End If
regIndex = regIndex - 1
Loop


So I set that custom action to run after ValidateProductID. But I still don't seem to be getting the service un-installed. Do custom actions run during an un-install? I only specified it for the "Install UI Sequence", not the "Install Exec Sequence" or any of the others, but I don't see an "Uninstall Sequence". Do I need to add it to one of these other sequences?
0 Kudos
benmarty
Level 3

Finally worked through the rest of the issue, I think. I added the custom action for loading the existing IS_SQLSERVER_SVCINSTANCE and related properties to the Install UI Sequence after ValidateProductID with the condition REMOVE <> "ALL", and added it to the Install Exec Sequence after ValidateProductID with the condition REMOVE = "ALL".
0 Kudos