如何在 Wix 中为输入的用户名和密码创建自定义 UI?

How to create custom UI for input username and password in Wix?

我在 运行Ning MSI 时安装 Web 服务,但默认情况下 运行Ning 在本地系统下。我希望它在登录到系统的特定用户下 运行。 我们可以通过更改服务 属性 上的日志来做到这一点,但我想在安装时这样做。 所以,我如何在 wix 中创建一个自定义 UI 来询问用户的用户名和密码。我有 2 个文件 - service.wxs 和 product.wxs 我正在尝试类似的东西:

    <?xml version="1.0" encoding="utf-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
      <Fragment>
        <UI Id="myUI">
            <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
            <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
            <Dialog Id="myDlg" Height="400" Width="550" Title="User Sample UI" >
              <Control Id="myEdit" Type="Edit" Property="USERNAME" Height="17"     Width="100" X="50" Y="50" Indirect="yes" Text="[USERNAME]"/>
              <Control Id="meEdit" Type="Edit" Property="PASSWORD"         Password="yes" Height="20" Width="100" X="80" Y="50" Indirect="yes" Text="[PASSWORD]"/>
        </Dialog>
      </UI>
  </Fragment>
    <Fragment>
        <DirectoryRef Id="FOLDER">
            <Component Id="..." Guid="*">
                <File Id="..." KeyPath="yes" Source="SourceDir\Service.exe" />              
                <wix:ServiceInstall Id="Install" Account="[USERNAME]" Password="[PASSWORD]" Name="...." Description="..." ErrorControl="ignore" Start="auto" Type="ownProcess" Vital="yes" Interactive="no"   xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"    xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" />

但这不起作用,我没有收到任何弹出窗口。 我也需要在 product.wxs 中提供一些参考吗?

请帮忙。

像这样添加一个新对话框。在主 UI 序列文件中添加对话框。

<UI>

  <Dialog Id="AccountDlg" Width="370" Height="270" Title="!(loc.InstallDirDlg_Title)">
    <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)" />
    <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />
    <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="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Please insert user account and password " />
    <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="{\Font_Title}User account and password " />
    <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)" />
    <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="AccountTitle" Type="Text" X="20" Y="60" Width="290" Height="18" NoPrefix="yes" Text="Enter user and password: " />
    <Control Id="AccountDis" Type="Text" X="20" Y="80" Width="100" Height="18" NoPrefix="yes" Text="User account name: " />
    <Control Id="AccountVar" Type="Edit" X="120" Y="80" Width="100" Height="18" Property="INSTALLED_USERNAME" Indirect="no" />
    <Control Id="PasswordDis" Type="Text" X="20" Y="110" Width="100" Height="18" NoPrefix="yes" Text="Password: " />
    <Control Id="PasswordVar" Type="Edit" X="120" Y="110" Width="100" Height="18" Property="PASSWORD" Indirect="no" Password="yes" />

  </Dialog>
</UI>

使用自定义操作集 属性 从目标计算机获取用户名和域。

<SetProperty Id="INSTALLED_USERNAME" Value="[%USERDOMAIN]\[%USERNAME]" Before="CostFinalize" Sequence="ui" />

设置默认密码。

<Property Id="PASSWORD" Value="A123456!"/>