如何将值从自定义对话框传递到组件
我创建了一个自定义对话框,允许用户配置我们正在安装的服务将在其下运行的帐户。为此,我将属性事件附加到自定义对话框上的“下一步”按钮,该按钮将设置 [帐户] 属性:
<Publish Property="Account" Value="[USERNAME]">USERACCOUNT = "1"</Publish>
<Publish Property="Account" Value="Local System"><![CDATA[USERACCOUNT <> "1"]]></Publish>
组件中选取帐户属性:
<Component Id="Service" Guid="*" >
<File Id="ServiceExe" KeyPath="yes" Source="$(var.ServiceFiles)\Service.exe" />
<ServiceInstall Vital="yes" ErrorControl="ignore" Type="ownProcess" Account="[Account]" Name="$(var.ServiceName)" Description="Service running as [Account]" Start="auto" />
<ServiceControl Id="ServiceControl" Remove="both" Name="$(var.ServiceName)" Start="install" Stop="both"/>
</Component>
然后,我尝试在安装服务的 问题是该组件不使用为 [Account] 发布的值,即使我可以看到安装程序日志中的属性事件正在发布正确的值。所以我的问题是如何确保服务安装程序组件获取自定义对话框发布的 [Account] 值?
I have created a custom dialog that allows the user to configure the account under which the service we are installing will run. I do this by attaching a property event to the Next button on my custom dialog that will set a [Account] property:
<Publish Property="Account" Value="[USERNAME]">USERACCOUNT = "1"</Publish>
<Publish Property="Account" Value="Local System"><![CDATA[USERACCOUNT <> "1"]]></Publish>
I then try to pick up the account property in the component that installs the service:
<Component Id="Service" Guid="*" >
<File Id="ServiceExe" KeyPath="yes" Source="$(var.ServiceFiles)\Service.exe" />
<ServiceInstall Vital="yes" ErrorControl="ignore" Type="ownProcess" Account="[Account]" Name="$(var.ServiceName)" Description="Service running as [Account]" Start="auto" />
<ServiceControl Id="ServiceControl" Remove="both" Name="$(var.ServiceName)" Start="install" Stop="both"/>
</Component>
My problem is that this component does not use the value published for [Account] even though I can see that the correct values are being published by the property event in the installer log. So my question is how can I ensure that the service installer component picks up the [Account] value published by my custom dialog ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用公共属性,例如 ACCOUNT。私有属性在 InstallExecuteSequence 中丢失其修改值。
此外,为特定帐户安装服务时,请确保
Use a public property, for example ACCOUNT. Private properties lose their modified values in InstallExecuteSequence.
Also, when installing a service for a specific account, make sure that the Log on as a service policy is set for that account. Otherwise the service will not start after installation.