安装过程中的Wix自定义操作失败

时间:2014-09-11 06:08:36

标签: windows wix windows-installer

我正在尝试使用自定义操作在安装期间(在复制文件之后)使用命令行选项运行程序。该操作需要管理员权限(它设置并安装Windows服务)。出于某种原因,自定义操作会一直失败。

我的wix代码:

<?xml version='1.0' encoding='Windows-1252'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<Product
Name='WHS 2011 Media Collector'
Id='28656223-C2E0-4E74-8503-B9D668056C4E'
UpgradeCode='84F31832-4E09-4149-A3F7-56A8DF63086F'
Language='1033'
Codepage='1252'
Version='3.0.0'
Manufacturer='Nick Radtke'>

<Package
  Id='*'
  Keywords='Installer'
  Platform="x64"
  Description="WHS 2011 Media Collector" Comments='Deployment Package for WHS 2011 Media Collector'
  Manufacturer='Nick Radtke'
  InstallerVersion='300'
  Languages='1033'
  Compressed='yes'
  SummaryCodepage='1252'
  InstallPrivileges='elevated'
  InstallScope='perMachine'/>

<Media
  Id='1'
  Cabinet='WSSSampleAddins.cab'
  EmbedCab='yes'
  DiskPrompt="CD-ROM #1" />

<Property Id='DiskPrompt' Value="Addins Installation [1]" />
<Property Id="LaunchApplication" Value="&quot;MediaCollectorServerService.exe&quot; -install"/>
<Property Id="MSIUSEREALADMINDETECTION" Value="1" />

<InstallExecuteSequence>
  <Custom Action='LaunchApplication' Before='InstallFinalize'>NOT Installed</Custom>
</InstallExecuteSequence>


<CustomAction Id="LaunchApplication"
                                BinaryKey="WixCA"
                                Impersonate="no"
              DllEntry="CAQuietExec64"
              Execute="deferred"
              Return="check"
              />

<Directory Id='TARGETDIR' Name='SourceDir'>
  <Directory Id='ProgramFiles64Folder' Name='PFiles'>
    <Directory Id="ParentAddinBinaryDir" Name="Nick Radtke">
      <Directory Id="AddinBinaryDir" Name="WHS 2011 Media Collector">
        <Component
          Id='WHS2011MCBinaryComponent'
          Guid='D21DA776-83F1-4F22-985B-FDB3C8ABD481'
          Win64='yes'>
          <RemoveFolder Id='AddinBinaryDir' On='uninstall' />
          <File
            Id='WHS2011MediaCollector.ListViewSubTab'
            Name='WHS2011MediaCollector.ListViewSubTab.dll'
            DiskId='1'
            Source='..\..\MediaCollectorAddIn\MediaCollector\TopLevelTab\bin\Release\WHS2011MediaCollector.ListViewSubTab.dll'
            ProcessorArchitecture='x64'
            KeyPath='yes'>
          </File>
          <File
            Id='WHS2011MediaCollector.TopLevelTab'
            Name='WHS2011MediaCollector.TopLevelTab.dll'
            DiskId='1'
            Source='..\..\MediaCollectorAddIn\MediaCollector\TopLevelTab\bin\Release\WHS2011MediaCollector.TopLevelTab.dll'
            ProcessorArchitecture='x64'
            KeyPath='no'>
          </File>
          <File
            Id='WHS2011MediaCollector.PicturesSubTab'
            Name='WHS2011MediaCollector.PicturesSubTab.dll'
            DiskId='1'
            Source='..\..\MediaCollectorAddIn\MediaCollector\TopLevelTab\bin\Release\WHS2011MediaCollector.PicturesSubTab.dll'
            ProcessorArchitecture='x64'
            KeyPath='no'>
          </File>
          <File
            Id='WHS2011MediaCollector.VideosSubTab'
            Name='WHS2011MediaCollector.VideosSubTab.dll'
            DiskId='1'
            Source='..\..\MediaCollectorAddIn\MediaCollector\TopLevelTab\bin\Release\WHS2011MediaCollector.VideosSubTab.dll'
            ProcessorArchitecture='x64'
            KeyPath='no'>
          </File>
          <File
            Id='WHS2011MediaCollector.SettingsSubTab'
            Name='WHS2011MediaCollector.SettingsSubTab.dll'
            DiskId='1'
            Source='..\..\MediaCollectorAddIn\MediaCollector\TopLevelTab\bin\Release\WHS2011MediaCollector.SettingsSubTab.dll'
            ProcessorArchitecture='x64'
            KeyPath='no'>
          </File>
          <File
            Id='NetLibrary'
            Name='NetLibrary.dll'
            DiskId='1'
            Source='..\..\MediaCollectorAddIn\MediaCollector\TopLevelTab\bin\Release\NetLibrary.dll'
            ProcessorArchitecture='x64'
            KeyPath='no'>
          </File>
          <File
            Id='Icon.png'
            Name='Icon.png'
            DiskId='1'
            Source='..\..\MediaCollectorAddIn\MediaCollector\TopLevelTab\bin\Release\Icon.png'
            ProcessorArchitecture='x64'
            KeyPath='no'>
          </File>
          <File
            Id='taglib_sharp'
            Name='taglib-sharp.dll'
            DiskId='1'
            Source='..\..\MediaCollectorAddIn\MediaCollector\TopLevelTab\bin\Release\taglib-sharp.dll'
            ProcessorArchitecture='x64'
            KeyPath='no'>
          </File>
          <File
            Id='MediaCollectorServerService.exe'
            Name='MediaCollectorServerService.exe'
            DiskId='1'
            Source='..\..\MediaCollectorServerService\x64\Release\MediaCollectorServerService.exe'
            ProcessorArchitecture='x64'
            KeyPath='no'>
          </File>
        </Component>
      </Directory>
    </Directory>

    <Directory Id="WindowsServerDir" Name="Windows Server">
      <Directory Id="WindowsServerBinDir" Name="Bin">
        <Directory Id="WindowsServerAddinsDir" Name="Addins">
          <Directory Id="WindowsServerPrimaryDir" Name="Primary">
            <Component
              Id='WHS2011MCXMLComponent'
              Guid='D21DA776-83F1-4F22-985B-FDB3C8ABD491'
              Win64='yes'>
              <File Id='WHS2011MCTopLevelTabXML'
                Name='WHS2011MediaCollector.addin'
                DiskId='1'
                Source='..\..\MediaCollectorAddIn\MediaCollector\TopLevelTab\bin\Release\WHS2011MediaCollector.addin'
                ProcessorArchitecture='x64'
                KeyPath='yes'>
              </File>
            </Component>
          </Directory>
        </Directory>
      </Directory>
    </Directory>
  </Directory>
</Directory>

<Feature Id='Complete' Level='1'>
  <ComponentRef Id='WHS2011MCBinaryComponent' />
  <ComponentRef Id='WHS2011MCXMLComponent' />
</Feature>
</Product>
</Wix>

这是我在msi日志中遇到的错误:

MSI (s) (40:30) [22:58:07:647]: Created Custom Action Server with PID 11672 (0x2D98).
MSI (s) (40:40) [22:58:07:663]: Running as a service.
MSI (s) (40:40) [22:58:07:663]: Hello, I'm your 32bit Elevated custom action server.
CAQuietExec64:  Error 0x80070002: Command failed to execute.
CAQuietExec64:  Error 0x80070002: CAQuietExec64 Failed
CustomAction LaunchApplication returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 22:58:07: InstallFinalize. Return value 3.
MSI (s) (40:D0) [22:58:07:694]: Note: 1: 2265 2:  3: -2147287035 

如果我以普通用户身份运行命令行,它会失败,但如果我以管理员用户(或系统用户)的身份运行它,它就可以运行。我很确定问题是对操作的权限。我已将其设置为延迟和Impersonate ='no',但它仍然无效。有人有任何提示吗?

编辑:所以,我发现启动应用程序中的明显快捷方式不适用于可执行文件的路径。有谁知道允许这个的语法?

1 个答案:

答案 0 :(得分:1)

结束了自己搞清楚。

更改了

<Property Id="LaunchApplication" Value="&quot;MediaCollectorServerService.exe&quot; -install"/>

行到

<SetProperty Id="LaunchApplication" Before="InstallInitialize" Sequence="execute" Value="&quot;[#MediaCollectorServerService.exe]%quot; -install"><![CDATA[NOT Installed AND LaunchApplication=""]]</SetProperty>

希望将来证明这对其他人有用。