Hi,

We have an installer that installs a managed Windows Service. 

The service listens to a http/s port and the installer gives the account that 
should execute the service access rights to listen to the port (ie netsh http 
add urlacl). 

When the installation is complete, we want to start the service and open a 
browser that points to the service. 

The access rights are given to the user using a managed Custom Action. 

During installation the user can select if a new account should be created for 
the service or if an existing account should be used.

If the user selects an existing account, everything is ok. The account gets the 
"logon as service" property set, the account gets the proper urlacl rights and 
the service is installed with the selected account and the service starts after 
installation.

However, if the user selects a new account, the service won't start. The user 
will be created with "logon as service" set and the service will be installed 
with the new user account. However, the service won't start because the account 
hasn't got the urlacl rights.

Looking at the logfile generated by msiexec we can see that the 
"PrepareAddHttpAdminNamespaceReservation" action hasn't been invoked. Why is 
that?

If we change the <ServiceControl> to NOT start the service during install (ie 
remove the start attribute from the element) everything is ok. The account gets 
created and given proper rights but the service obviously not started. I can 
however start the service manually after installation.

We have tried to move the custom actions for urlacls as early as possible in 
the install sequence but without success. 

Any hints?

We use the stable release of WiX 3.6

Below is the relevant parts from our WiX project (the USERSOURCE property is 
set by a custom dialog). 

Regards,
Anders Pålsson



<?xml version="1.0" encoding="UTF-8"?>
<?include defines.wxi ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi";
     xmlns:fw="http://schemas.microsoft.com/wix/FirewallExtension";
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension";
     xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension";>

    <Product Id="*" ...>
                <Package Manufacturer="$(var.Manufacturer)" 
Description="$(var.ApplicationName)"
            InstallPrivileges="elevated"  InstallScope="perMachine" 
InstallerVersion="200" Compressed="yes" />
                <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />

        <Condition Message="You need to be an administrator to install this 
product.">
            Privileged
        </Condition>

        <Property Id="PORTADMIN" Value="6247"/>

        <!-- Properties -->
        <Property Id="SERVICE_ACCOUNT" Secure="yes"/>
        <Property Id="SERVICE_ACCOUNT_PASSWORD" Hidden="no" Secure="yes"/>
        <Property Id="SERVICE_ACCOUNT_VERIFIED" Value="0"/>
        <Property Id="SERVICE_ACCOUNT_DOMAIN" Secure="yes"/>
        <Property Id="INSTALL_SERVICE_ACCOUNT" Secure="yes"/>

        <Property Id="USERSOURCE" Value="$(var.USERSOURCE_NEW)"/>

        <Binary Id="MobileSetupCustomActions" 
SourceFile="..\CustomAction\bin\release\CustomAction.CA.dll"/>

        <!-- actions that adds urlacl for HTTP ADMIN port-->
        <CustomAction Id="PrepareAddHttpAdminNamespaceReservation" 
Property="AddHttpAdminNamespaceReservation"
                      
Value="SERVICEACCOUNT=[SERVICE_ACCOUNT];PORTADMIN=[PORTADMIN]"/>
        <CustomAction Id="AddHttpAdminNamespaceReservation" 
DllEntry="AddHttpAdminReservation" BinaryKey="MobileSetupCustomActions"
                      Execute="commit" Impersonate="no"/>

        <!-- Action that launches the configuration page after installation -->
        <Property Id="WixShellExecTarget" Value="http://localhost:6247/admin/"; 
/>
        <CustomAction Id="LaunchConfiguration" BinaryKey="WixCA" 
DllEntry="WixShellExec" Impersonate="yes"/>
        
        <InstallExecuteSequence>
            <RemoveExistingProducts Before="InstallInitialize"/>
            
            <!-- Add urlacl for HTTP ADMIN if installing -->
            <Custom Action="PrepareAddHttpAdminNamespaceReservation" 
After="InstallInitialize">
                NOT Installed
            </Custom>
            <Custom Action="AddHttpAdminNamespaceReservation" 
After="PrepareAddHttpAdminNamespaceReservation">
                NOT Installed
            </Custom>
            
            <Custom Action="LaunchConfiguration" After="InstallFinalize">
                NOT Installed
            </Custom>
        </InstallExecuteSequence>
        
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="OurCompany" Name="OurCompany">
                    <Directory Id="INSTALLLOCATION" 
Name="$(var.ApplicationName)">
                                                <Component Id="Mobile.Service" 
Guid="91145245-040F-44FA-A989-D1E97857EA64">
                            <File Source="WindowsServiceHost.exe"/>
                        </Component>

                                                <Component 
Id="CreateServiceUser" Guid="B2B32FCC-5CC1-4907-A7C6-A46684BC0280">
                            <Condition>USERSOURCE = 
$(var.USERSOURCE_NEW)</Condition>
                            <CreateFolder/>
                            <util:User Id="UserCreateServiceUser" 
Name="[SERVICE_ACCOUNT]" CreateUser="yes" LogonAsService="yes"
                                       RemoveOnUninstall="no"
                                       Domain="[SERVICE_ACCOUNT_DOMAIN]" 
Password="[SERVICE_ACCOUNT_PASSWORD]"/>
                        </Component>

                        <Component Id="UpdateServiceUser" 
Guid="3FD19D72-D99B-4B27-9B26-F1D1F25D7850">
                            <Condition>USERSOURCE = 
$(var.USERSOURCE_EXISTING)</Condition>
                            <CreateFolder/>
                            <util:User Id="UpdateServiceUser" 
Name="[SERVICE_ACCOUNT]" LogonAsService="yes" CreateUser="no" 
UpdateIfExists="yes" />
                        </Component>
                        
                        <Component Id="ServiceHost" 
Guid="91F63654-18DC-45A0-A585-78F3D1AE09EF">
                            <File Source="WindowsServiceHost.exe"/>

                            <ServiceInstall Name="my-service" 
                                            DisplayName = "$(var.Manufacturer) 
$(var.ApplicationName)"
                                            Description="$(var.Description)"
                                            Account="[INSTALL_SERVICE_ACCOUNT]"
                                            
Password="[SERVICE_ACCOUNT_PASSWORD]"
                                            Type="ownProcess" 
                                            Start="auto" 
                                            ErrorControl="normal" 
                                            Vital="yes"
                                            />
                                                                                
        
                            <ServiceControl Id="MobilityServiceControl" 
Name="my-service" 
                                            Start="install" Stop="both" 
Wait="yes" Remove="uninstall"/>                            
                        </Component>
                    </Directory>
                </Directory>
            </Directory>           
        </Directory>        

        <Feature Id="Full" Level="1">
            <ComponentRef Id="Mobile.Service"/>
            <ComponentRef Id="CreateServiceUser"/>
            <ComponentRef Id="UpdateServiceUser"/>
            <ComponentRef Id="ServiceHost"/>
        </Feature>

        <UI Id="LimeForSmartphonesSetup">
            <UIRef Id="WixUI_InstallDir"/>
            
            <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" 
Value="SelectDatasourceDialog" Order="2">1</Publish>
            <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" 
Value="SelectUserDialog" Order="2">1</Publish>
        </UI>
        <WixVariable Id="WixUIBannerBmp" Value="Resources\setupBanner.bmp" />
        <WixVariable Id="WixUIDialogBmp" Value="Resources\setupDialog.bmp" />   
     
    </Product>
</Wix>


------------------------------------------------------------------------------
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to