I have an MSI which installs a windows service as either LocalSystem ot CustomAccount depending on what the user selects using a Condition. Occasionally the MSI would fail to uninstall, the files were removed but the service was not removed from the services.msc window. I have come up with two potential causes and resolutions:
1) I created lots of these MSI's all based on each other and many of them have the same Guid for the ServiceInstall Component. Does this cause issues between two completely seperate MSI's? This kind of relates to why it only happens very infrequently. 2) Whether an install is carried out using LocalSystem or Custom account is determined by a value in a property called SERVICE_LOGON_TYPE which is set by the user in the UI on install. However the MSI has no idea what this value is when uninstalling, so do I need to save the SERVICE_LOGON_TYPE and maybe the service username as a registry setting? If I do need to do this, why does it work so often and only fail once in a while? Code Below: <!-- Install the service using a custom account. --> <Component Id ='$(var.ServiceExecutableName).CustomAccount.Component' Guid='C99E22D5-153F-460E-9CE0-CFC395049513'> <Condition>SERVICE_LOGON_TYPE = "CUSTOM_ACCOUNT"</Condition> <!-- The user account to install the service under. --> <util:User Id='User' CreateUser='no' LogonAsService='yes' Domain='[SERVICE_DOMAIN]' Name='[SERVICE_USERNAME]' Password='[SERVICE_PASSWORD]' UpdateIfExists='yes'/> <File Id='$(var.ServiceExecutableName).CustomAccount' Name='$(var.ServiceExecutableName)' Source='$(var.AssembliesPath)\$(var.ServiceExecutableName)' Vital='yes' KeyPath='yes'/> <!-- Controls how the service is installed. --> <ServiceInstall Id='$(var.ServiceExecutableName).ServiceInstall.CustomAccount' DisplayName='$(var.ApplicationManufacturer) $(var.ApplicationName) $(var.ServiceDescription)' Name='$(var.ServiceName)' Description='$(var.ApplicationManufacturer) $(var.ApplicationName) $(var.ServiceDescription) $(var.ApplicationVersion) ($(var.ServiceName))' ErrorControl='normal' Start='auto' Type='ownProcess' Vital='yes' Interactive='no' Account='[SERVICE_DOMAIN]\[SERVICE_USERNAME]' Password='[SERVICE_PASSWORD]' /> <!-- Controls how the service is started. --> <ServiceControl Id='$(var.ServiceExecutableName).ServiceControl.Start.CustomAccount' Name='$(var.ServiceName)' Start='install' Wait='no'/> <!-- Controls how the service is stopped and removed. --> <ServiceControl Id='$(var.ServiceExecutableName).ServiceControl.StopRemove.CustomAccount' Name='$(var.ServiceName)' Stop='uninstall' Remove='uninstall' Wait='yes'/> </Component> <!-- Install the service using a local system account. --> <Component Id ='$(var.ServiceExecutableName).LocalSystem.Component' Guid='D11F0BE4-1137-48E9-AF28-D98490FC9B0B'> <Condition>SERVICE_LOGON_TYPE = "LOCAL_SYSTEM"</Condition> <File Id='$(var.ServiceExecutableName).LocalSystem' Name='$(var.ServiceExecutableName)' Source='$(var.AssembliesPath)\$(var.ServiceExecutableName)' Vital='yes' KeyPath='yes'/> <!-- Controls how the service is installed. --> <ServiceInstall Id='$(var.ServiceExecutableName).ServiceInstall.LocalSystem' DisplayName='$(var.ApplicationManufacturer) $(var.ApplicationName) $(var.ServiceDescription)' Name='$(var.ServiceName)' Description='$(var.ApplicationManufacturer) $(var.ApplicationName) $(var.ServiceDescription) $(var.ApplicationVersion) ($(var.ServiceName))' ErrorControl='normal' Start='auto' Type='shareProcess' Vital='yes' Interactive='no' /> <!-- Controls how the service is started. --> <ServiceControl Id='$(var.ServiceExecutableName).ServiceControl.Start.LocalSystem' Name='$(var.ServiceName)' Start='install' Wait='no'/> <!-- Controls how the service is stopped and removed. --> <ServiceControl Id='$(var.ServiceExecutableName).ServiceControl.StopRemove.LocalSystem' Name='$(var.ServiceName)' Stop='uninstall' Remove='uninstall' Wait='yes'/> </Component> <!-- This property is persisted in the registry on install. On uninstall read the property value from the registry. --> <Component Id="ServiceLogonType.Property.Component" Guid="4C034470-BAB5-41F5-803D-4989F1A4BD59"> <RegistryKey Id='ServiceLogonType.Property.RegistryKey' Key='Software\$(var.ApplicationManufacturer)\$(var.ApplicationName)\$(var.ServiceDescription)' Root='HKLM' Action='createAndRemoveOnUninstall'> <RegistryValue Id='ServiceLogonType.Property.RegistryValue' Name='ServiceLogonType' Type='string' Value='[SERVICE_LOGON_TYPE]' KeyPath="yes" /> </RegistryKey> </Component> <Component Id="ServiceDomain.Property.Component" Guid="ADD395EC-CA64-4664-9E68-5AE59A0B4744"> <Condition>SERVICE_LOGON_TYPE = "CUSTOM_ACCOUNT"</Condition> <RegistryKey Id='ServiceDomain.Property.RegistryKey' Key='Software\$(var.ApplicationManufacturer)\$(var.ApplicationName)\$(var.ServiceDescription)' Root='HKLM' Action='createAndRemoveOnUninstall'> <RegistryValue Id='ServiceDomain.Property.RegistryValue' Name='ServiceDomain' Type='string' Value='[SERVICE_DOMAIN]' KeyPath="yes" /> </RegistryKey> </Component> <Component Id="ServiceUsername.Property.Component" Guid="85301D03-5F1F-4A30-9F72-170290AE82A0"> <Condition>SERVICE_LOGON_TYPE = "CUSTOM_ACCOUNT"</Condition> <RegistryKey Id='ServiceUsername.Property.RegistryKey' Key='Software\$(var.ApplicationManufacturer)\$(var.ApplicationName)\$(var.ServiceDescription)' Root='HKLM' Action='createAndRemoveOnUninstall'> <RegistryValue Id='ServiceUsername.Property.RegistryValue' Name='ServiceUsername' Type='string' Value='[SERVICE_USERNAME]' KeyPath="yes" /> </RegistryKey> </Component> <!-- ***** Service Logon Settings ***** --> <!-- Determines the type of install to carry out. LOCAL_SYSTEM install or CUSTOM_ACCOUNT --> <!-- Determines the type of install to carry out. LOCAL_SYSTEM install or CUSTOM_ACCOUNT --> <Property Id="SERVICE_LOGON_TYPE" Value="LOCAL_SYSTEM"> <!-- This property is persisted in the registry on install. On uninstall read the property value from the registry. --> <!--<RegistrySearch Id="ServiceLogonType.RegistrySearch" Root="HKLM" Key="Software\$(var.ApplicationManufacturer)\$(var.ApplicationName)\$(var.ServiceDescription)" Name="ServiceLogonType" Type="raw" />--> </Property> <!-- If CUSTOM_ACCOUNT then use the following values for Domain, Username and Password --> <Property Id='SERVICE_DOMAIN' Value='GLOBAL'> <!--<RegistrySearch Id="ServiceDomain.RegistrySearch" Root="HKLM" Key="Software\$(var.ApplicationManufacturer)\$(var.ApplicationName)\$(var.ServiceDescription)" Name="ServiceDomain" Type="raw" />--> </Property> <Property Id='SERVICE_USERNAME' Value=' '> <!--<RegistrySearch Id="ServiceUsername.RegistrySearch" Root="HKLM" Key="Software\$(var.ApplicationManufacturer)\$(var.ApplicationName)\$(var.ServiceDescription)" Name="ServiceUsername" Type="raw" />--> </Property> <Property Id='SERVICE_PASSWORD' Value=' ' /> <Property Id='SERVICE_PASSWORD_CONFIRM' Value=' ' /> -- View this message in context: http://n2.nabble.com/Windows-Service-Uninstall-Failing-Intermittently-tp2956986p2956986.html Sent from the wix-users mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://www.creativitycat.com _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users