Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
690 views
in Technique[技术] by (71.8m points)

xml - wix service install not enough permission

I'm trying to create an installer with WiX for a window service, I tried all the answers that I had found and nothing. The installer created with WiX still won't install because of permission, not enough permission... this is my code...

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'><?define G_TargetDir=$(var.G.TargetDir)?>
    <Product Id="*" Name="G.Installer" Language="1033" Version="1.0.0.0" Manufacturer="" UpgradeCode="PUT-GUID-HERE">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <MediaTemplate EmbedCab="yes" />

        <Feature Id="ProductFeature" Title="G.Installer" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
        </Feature>
    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="G.Installer" />          
            </Directory>
        </Directory>
    </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
            <Component Id="G.exe" Guid="*">
              <File Id="G.exe" Name="G.exe" Source="$(var.G_TargetDir)G.exe" Vital="yes" KeyPath="yes" />
        <ServiceInstall Id="G.exe" Type="ownProcess" Vital="yes" Name="G.exe" DisplayName="G" Description="Description" Start="auto" Account="LocalSystem" ErrorControl="critical" Arguments="-start" Interactive="yes">
          <util:PermissionEx  User="Everyone" ServicePauseContinue="yes" ServiceQueryStatus="yes" ServiceStart="yes" ServiceStop="yes" ServiceUserDefinedControl="yes" />
        </ServiceInstall>
        <ServiceControl Id="G.exe" Stop="both" Start="install" Remove="uninstall" Name="G.exe" Wait="no"/>
            </Component>
            <Component Id="G.exe.config" Guid="*">
              <File Id="G.exe.config" Name="G.exe.config" Source="$(var.G_TargetDir)G.exe.config" />
            </Component>
            <Component Id="MongoDB.Bson.dll" Guid="*">
              <File Id="MongoDB.Bson.dll" Name="MongoDB.Bson.dll" Source="$(var.G_TargetDir)MongoDB.Bson.dll" />
            </Component>
            <Component Id="System.Buffers.dll" Guid="*">
              <File Id="System.Buffers.dll" Name="System.Buffers.dll" Source="$(var.G_TargetDir)System.Buffers.dll" />
            </Component>
            <Component Id="DnsClient.dll" Guid="*">
              <File Id="DnsClient.dll" Name="DnsClient.dll" Source="$(var.G_TargetDir)DnsClient.dll" />
            </Component>
            <Component Id="System.Runtime.InteropServices.RuntimeInformation.dll" Guid="*">
              <File Id="System.Runtime.InteropServices.RuntimeInformation.dll" Name="System.Runtime.InteropServices.RuntimeInformation.dll" Source="$(var.G_TargetDir)System.Runtime.InteropServices.RuntimeInformation.dll" />
            </Component>
            <Component Id="MongoDB.Driver.Core.dll" Guid="*">
              <File Id="MongoDB.Driver.Core.dll" Name="MongoDB.Driver.Core.dll" Source="$(var.G_TargetDir)MongoDB.Driver.Core.dll" />
            </Component>
            <Component Id="MongoDB.Driver.dll" Guid="*">
              <File Id="MongoDB.Driver.dll" Name="MongoDB.Driver.dll" Source="$(var.G_TargetDir)MongoDB.Driver.dll" />
            </Component>
        </ComponentGroup>
    </Fragment>
</Wix>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

InstallPrivileges: Before trying anything else, can you please set the InstallPrivileges attribute of the Package element to "elevated"? Just to make sure - I think elevated is default (once InstallScope is perMachine at least?).


Compiling?: It is not quite clear what happens. Does the WiX project fail to compile? The first thing that looks odd is that you have no Manufacturer value - maybe you redacted it before posting? As far as I know WiX 3 will refuse to compile unless Manufacturer has a value. If it is missing, please add it.

<Product Id="*" Name="G.Installer" Language="1033" Version="1.0.0.0" 
         Manufacturer="YOURCOMPANYNAMEHERE" UpgradeCode="PUT-GUID-HERE">

Setup Behavior: If the setup compiles, does it start to install when run, but fail to complete? Or does it complete and the service fails to start? Are you installing with an administrator account and getting a UAC prompt when you kick off the install?


Logging: We need some more information what happens, and if the setup fails to install you should enable MSI logging to see what is going on. First you check the system's event logs, and then you run your setup installation whilst enabling verbose MSI logging. I like to enable logging for all MSI installations. Minor performance hit, but a real log-file is always available when you suddenly need one. You can enable logging for all MSI files as explained on installsite.org (section: "Globally for all setups on a machine"). MSI log files will then just sit in your %TEMP% folder after installation. They have a random hex name, and you can flush them all regularly so they don't pile up. You sort by modify date / time to find the latest one(s) created - obviously. Some logging and log-file interpretation hints can be found here.


Suggestions: 1: I would try to set up the files needed to run the service manually on a virtual machine and register them to verify that the service runs without problems. 2: Do a complete rebuild of the WiX setup deleting any temporary files and wixobj files. It is possible that your installer just does not compile, but that it links with pre-existing wixobj files from a previous compile. A "high astonishment" factor (linking with outdated files).


Service Startup Problems: And just to state the obvious: if the service fails to start, enable its maximal logging level and check the event log and whatever other logging you might have. Run dependency checking (Dependencies.exe - rewrite of Dependency Walker) and check assembly binding. Check for dev-box sins in your config file (hard coded erroneous values), Etc... Don't need to tell you this, but it is my usual checklist (that somebody downvoted for some reason, let me know what errors you find in there maybe? I am a deployment specialist not a coder - it is more of an "ideas" list than a true checklist).


Source Simplification: WiX source files can normally be simplified as explained here: Syntax for guids in WIX? Sample:

<Component Id="System.Runtime.InteropServices.RuntimeInformation.dll" Guid="{00000000-0000-0000-0000-000000000000}">
   <File Id="System.Runtime.InteropServices.RuntimeInformation.dll" Name="System.Runtime.InteropServices.RuntimeInformation.dll" Source="$(var.G_TargetDir)System.Runtime.InteropServices.RuntimeInformation.dll" />
 </Component>

vs

<Component>
   <File Source="$(var.G_TargetDir)System.Runtime.InteropServices.RuntimeInformation.dll" />
 </Component>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...