WiX Service Account Dialog

May 30, 2008 - Kjell-Åke Gafvelin

In my current project we had a need to be able to enter the service account details during setup for the service which is hosting our WCF services. I couldn’t find a dialog that does this using WiX so I created my own.

Service dialog

In my setup project I used the WIXUI_FeatureTree template as a base. To “hook in” the new dialog you will have to override the template because if you just add new Publish elements they will not override the existing elements.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<UIRef Id="WixUI_ErrorProgressText"/>
<UIRef Id="WixUI_Common" />

<Binary Id="WarningIcon" SourceFile="warning.bmp"/>

<UI Id="MyWixUI_FeatureTree">
    <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
    <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
    <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />

    <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
    <Property Id="WixUI_Mode" Value="FeatureTree" />

    <DialogRef Id="ErrorDlg" />
    <DialogRef Id="FatalError" />
    <DialogRef Id="FilesInUse" />
    <DialogRef Id="MsiRMFilesInUse" />
    <DialogRef Id="PrepareDlg" />
    <DialogRef Id="ProgressDlg" />
    <DialogRef Id="ResumeDlg" />
    <DialogRef Id="UserExit" />

    <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>

    <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>

    <Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
    <Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="CustomizeDlg">LicenseAccepted = "1"</Publish>

    <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="1">Installed</Publish>
    <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg" Order="2">NOT Installed</Publish>
    <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="ServiceAccountDlg" Order="1">1</Publish>

    <Publish Dialog="ServiceAccountDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg">1</Publish>
    <Publish Dialog="ServiceAccountDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>

    <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="ServiceAccountDlg" Order="1">NOT Installed OR WixUI_InstallMode = "Change"</Publish>
    <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed</Publish>

    <Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>

    <Publish Dialog="MaintenanceTypeDlg" Control="ChangeButton" Event="NewDialog" Value="CustomizeDlg">1</Publish>
    <Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
    <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
    <Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>

    <Dialog Id="ServiceAccountDlg" Width="370" Height="270" Title="[ProductName] Setup">
        <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />

        <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)">
            <Condition Action="disable"><![CDATA[ACCOUNT = "" OR PASSWORD = ""]]></Condition>
            <Condition Action="enable">ACCOUNT &lt;&gt; "" AND PASSWORD &lt;&gt; ""</Condition>
        </Control>

        <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
            <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
        </Control>

        <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
        <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
        <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
        <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Enter service account details." />
        <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="{\WixUI_Font_Title}Service account" />
        <Control Type="Text" Width="322" Height="26" X="25" Y="56" Id="BodyLabel" Text="Specify the logon account for the [ProductName] service." NoPrefix="yes" />
        <Control Type="Text" Width="275" Height="10" X="25" Y="98" Id="AccountLabel" Text="&amp;Account name (Example: domain\user or user@domain):" />
        <Control Type="Edit" Width="194" Height="15" X="25" Y="111" Id="AccountTextbox" Property="ACCOUNT" />
        <Control Type="Text" Width="275" Height="10" X="25" Y="135" Id="PasswordLabel" Text="Pa&amp;ssword:" />
        <Control Type="Edit" Width="194" Height="15" X="25" Y="148" Id="PasswordTextbox" Property="PASSWORD" Password="yes" />

        <Control Width="12" Height="12" FixedSize="yes" Type="Bitmap" X="25" Y="170" Id="Warning" Text="WarningIcon"/>
        <Control Id="WarningLabel" Type="Text" X="40" Y="170" Width="200" Height="40" Text="The account entered here will not be validated. Make sure that the account details entered are correct." />
    </Dialog>
</UI>

My sideprojects