我正在运行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" />
但这不起作用,我没有弹出任何东西。 我是否还需要在product.wxs中提供一些参考?
请帮忙。
答案 0 :(得分:4)
添加一个像这样的新对话框。在主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!"/>