[英]Wix Installer and run with User fails
几天没有找到解决方案后,我决定问你。 希望可以有人帮帮我。
我创建了一个WIX项目,该项目应安装Windows服务,然后由特殊用户运行该服务。 (请记住,过去我们使用的是VS2010的旧安装程序项目,在该项目中我们做的完全一样。因此目标计算机上的用户存在并且可以执行此操作。)可悲的是,每次出现日志条目“错误1920。 “ TransformService”无法启动。请确认您具有足够的特权来启动系统服务。”
首先,这里是我们正在使用的代码:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product Id="*" Name="Installation" Language="1033" Version="1.0.0.0" Manufacturer="Company" UpgradeCode="901a337d-3a75-49b5-b345-134684d73442">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<!-- move install directory selected in wizzard to installation -->
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLLOCATION" />
<!-- check if drive E: exist and set as default -->
<Property Id="NEWINSTALLDIR" Value="E:\">
<DirectorySearch Id="SearchNewDefaultInstallRoot" Path="E:\" Depth="1" />
</Property>
<CustomAction Id="DirectorySet" Property="TARGETDIR" Value="[NEWINSTALLDIR]" />
<CustomAction Id="InstallDirectorySet" Directory="INSTALLLOCATION" Value="com\serviceFolder" />
<InstallExecuteSequence>
<Custom Action="DirectorySet" Before="LaunchConditions">TARGETDIR="E:\"</Custom>
<Custom Action="InstallDirectorySet" After="CostFinalize">INSTALLLOCATION="com\serviceFolder"</Custom>
</InstallExecuteSequence>
<Property Id="DOMAIN" Value="com" Secure="yes" />
<Property Id="SERVICE_USER" Value="user1" Secure="yes" />
<Property Id="SERVICE_USER_PASSWORT" Value="pw1" Secure="yes" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<!--embed CAB-Package in msi file-->
<MediaTemplate CompressionLevel="high" EmbedCab="yes" />
<!-- define which components will be part of installation -->
<Feature Id="ProductFeature" Title="Installation Target" Level="1">
<ComponentRef Id="ProductStartComponent" />
<ComponentGroupRef Id="GeneratedFiles" />
</Feature>
<!-- define type of installation wizzard -->
<UIRef Id="WixUI_InstallDir" />
</Product>
<!-- define installation location -->
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLLOCATION" Name="serviceFolder">
<Component Id="ProductStartComponent" Guid="" KeyPath="yes">
<util:User Id="UpdateUserLogonAsService"
UpdateIfExists="yes"
FailIfExists="no"
CreateUser="no"
Name="[DOMAIN]\[SERVICE_USER]"
LogonAsService="yes"/>
<ServiceInstall Id="ServiceInstaller"
Type="ownProcess"
Vital="yes"
Name="TransformService"
DisplayName="My TransformService"
Description="My TransformService description"
Start="auto"
Account="[DOMAIN]\[SERVICE_USER]"
Password="[SERVICE_USER_PASSWORT]"
ErrorControl="normal"
Interactive="no">
</ServiceInstall>
<ServiceControl Id="ServiceControl_Start" Name="TransformService" Start="install" Wait="no" />
<ServiceControl Id="ServiceControl_Stop" Name="TransformService" Stop="both" Remove="uninstall" Wait="yes" />
</Component>
</Directory>
</Directory>
</Directory>
</Fragment>
</Wix>
这是生成的文件(* .wxs):
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="INSTALLLOCATION">
<Component Id="cmpA36C3656F2234BFB24DBB332EC935E09" Guid="*">
<File Id="filABEE616FA22E22792C8C1D1DC9BCEC47" KeyPath="yes" Source="$(var.ServiceFilesDir)\MyLib.dll" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="GeneratedFiles">
<ComponentRef Id="cmpA36C3656F2234BFB24DBB332EC935E09" />
</ComponentGroup>
</Fragment>
</Wix>
生成的文件将由我的Wix项目使用以下命令创建
<Target Name="BeforeBuild"> <HeatDirectory ... /> </Target>
好吧,如果这还不够,请说一个字,我会更详细地描述它。 也许有人已经发现了问题。
编辑:我已经看到许多示例,其中所有示例都在component元素中也设置了exe文件,在其中也是ServiceInstall元素。 所以我在使用一些XSLT转换后做了同样的事情。 现在,我看到我的服务有异常行为。 显然,它尝试启动服务,并生成了一些日志文件。 奇怪的是,它会生成多个它,通常它只能是一个! 安装程序对话框将继续挂在与bevor相同的位置。 “开始服务”。 有人有主意吗?
这又是代码:
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLLOCATION" Name="serviceFolder">
<File Id="fil1B3AEFCBBA787AF73A7D8BE34AC0F615" KeyPath="yes" Source="$(var.FilesDir)\Service.Host.exe" />
<File Id="filDA3F2F6204CEA1AF93216D42BF163D93" Source="$(var.FilesDir)\Service.Host.exe.config" />
<Component Id="ProductStartComponent" Guid="50451FB8-1473-4BDD-FE1F-AAB2B7B3A4CD">
<util:User Id="UpdateUserLogonAsService"
UpdateIfExists="yes"
FailIfExists="no"
CreateUser="no"
Name="[DOMAIN]\[SERVICE_USER]"
LogonAsService="yes"/>
<ServiceInstall Id="ServiceInstaller"
Type="ownProcess"
Vital="yes"
Name="TransformService"
DisplayName="My TransformService"
Description="My TransformService description"
Start="auto"
Account="[DOMAIN]\[SERVICE_USER]"
Password="[SERVICE_USER_PASSWORD]"
ErrorControl="normal"
Interactive="no">
</ServiceInstall>
<ServiceControl Id="Service.Host.exe"
Name="Service.Host.exe"
Start="install"
Stop="both"
Remove="uninstall"
Wait="no" />
</Component>
</Directory>
</Directory>
</Directory>
</Fragment>
谢谢和问候亚历克斯
好吧,我发现了问题。 在我的项目中,我使用ServiceBase类来检查是否必须将我的服务作为控制台应用程序或Windows服务启动。 问题就在这里。 它试图将其作为控制台应用程序启动。 :(修复它运行良好之后。
对不起,打扰您了!
好吧,我可以问您其他问题。 我想在安装对话框中将起始路径设置为另一个驱动器和路径,例如: E:\\ servicefolder \\ myservice 。 遗憾的是,我所做的所有更改都将被忽略,并且使用标准路径C:\\ Program Files ...有人可以帮助我吗?
亚历克斯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.