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

Jam*_*mes 1 wix wix3

我在运行 MSI 时安装 Web 服务,但默认情况下在本地系统下运行。我希望它在登录系统的特定用户下运行。我们可以通过更改服务的登录属性来做到这一点,但我想在安装时执行此操作。那么,我如何在 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" />
Run Code Online (Sandbox Code Playgroud)

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

请帮忙。

Ark*_*sky 5

添加一个像这样的新对话框。在主 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>
Run Code Online (Sandbox Code Playgroud)

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

<SetProperty Id="INSTALLED_USERNAME" Value="[%USERDOMAIN]\[%USERNAME]" Before="CostFinalize" Sequence="ui" />
Run Code Online (Sandbox Code Playgroud)

设置默认密码。

<Property Id="PASSWORD" Value="A123456!"/>
Run Code Online (Sandbox Code Playgroud)