简体   繁体   English

Wix安装程序并与用户一起运行失败

[英]Wix Installer and run with User fails

after a few days of not finding a solution i decided to asking you. 几天没有找到解决方案后,我决定问你。 Hope someone can help me. 希望可以有人帮帮我。

I created a WIX Project that should install a Windows Service and run this service afterwards by a special User. 我创建了一个WIX项目,该项目应安装Windows服务,然后由特殊用户运行该服务。 (keep in mind in the past we used the old installer project of VS2010 in which we did exactly the same. So the user on the target machine exists and can do that.) Sadly i got every time the log entry "Error 1920. Service 'TransformService' failed to start. Verify that you have sufficient privileges to start system services.". (请记住,过去我们使用的是VS2010的旧安装程序项目,在该项目中我们做的完全一样。因此目标计算机上的用户存在并且可以执行此操作。)可悲的是,每次出现日志条目“错误1920。 “ TransformService”无法启动。请确认您具有足够的特权来启动系统服务。”

First of all here my Code that we are using: 首先,这里是我们正在使用的代码:

<?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>

Here is the generated file (*.wxs): 这是生成的文件(* .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>

The generated File will be created by my Wix-Project using this 生成的文件将由我的Wix项目使用以下命令创建

<Target Name="BeforeBuild"> <HeatDirectory ... /> </Target>

Well if this is not enough information please say a word an i will describe it in more details. 好吧,如果这还不够,请说一个字,我会更详细地描述它。 Maybe someone found already the problem. 也许有人已经发现了问题。

EDIT: I have seen many examples in which all set the exe-file in the component element in which is also the ServiceInstall element. 编辑:我已经看到许多示例,其中所有示例都在component元素中也设置了exe文件,在其中也是ServiceInstall元素。 So i did the same after using some XSLT transformation. 所以我在使用一些XSLT转换后做了同样的事情。 Now i see a strange behavior of my service. 现在,我看到我的服务有异常行为。 Apparently it tries to start the service and it generates some log-files. 显然,它尝试启动服务,并生成了一些日志文件。 The strange thing is, it generates multiple of it and normally it should only be one! 奇怪的是,它会生成多个它,通常它只能是一个! The installer dialog keeps hanging at the same position as bevor. 安装程序对话框将继续挂在与bevor相同的位置。 "Starting Service". “开始服务”。 Does someone has an idea? 有人有主意吗?

Here is the Code again: 这又是代码:

<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>

Thanks & Greets Alex 谢谢和问候亚历克斯

Well i found the problem. 好吧,我发现了问题。 In my project i used the ServiceBase-class for checking if i have to start my service as console application or windows service. 在我的项目中,我使用ServiceBase类来检查是否必须将我的服务作为控制台应用程序或Windows服务启动。 And there lies the problem. 问题就在这里。 It tried to start it as console application. 它试图将其作为控制台应用程序启动。 :( After fixing that it was running nicely. :(修复它运行良好之后。

Sorry to disturb you! 对不起,打扰您了!

Well may i ask you about some other problem. 好吧,我可以问您其他问题。 I would like to set the starting path in install dialog to another drive and path like: E:\\servicefolder\\myservice . 我想在安装对话框中将起始路径设置为另一个驱动器和路径,例如: E:\\ servicefolder \\ myservice Sadly all my changes will be ignored and it uses the standard path C:\\Program Files... Can someone help me? 遗憾的是,我所做的所有更改都将被忽略,并且使用标准路径C:\\ Program Files ...有人可以帮助我吗?

Thx Alex 亚历克斯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM