簡體   English   中英

Wix安裝程序並與用戶一起運行失敗

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM