English 中文(简体)
安装完成后,开启UAC并启动应用程序。
原标题:Launch application after installation complete, with UAC turned on

我一直在使用WIX(Windows Installer XML)技术构建我们产品的安装程序。预期的行为是安装后,如果勾选了复选框,则启动产品。

这已经运作了一段时间,但我们最近发现Win 7和Vista的UAC阻止了应用程序的启动。我进行了一些研究,有人建议我应该添加属性。

执行 = 延迟 和 模拟 = 否。

我已经这样做了,但是后来发现,为了执行延迟,必须在InstallInitialize和IntallFinalize阶段之间执行CustomAction;这不是我所需要的。如果勾选了启动复选框,我需要在安装完成后启动产品。是否有其他提升权限的方法?

任何回答,建议或推理,我们都会欣然接受。

问题回答

不幸的是,Rob提到的主题在Windows Vista或7上并不真正有用,尤其是在UAC打开时。

我解决这个问题的方法是使用CustomAction来启动命令提示符并运行所需应用程序。

<CustomAction 
    Id="LaunchApp" 
    Directory="YourDirectory" 
    ExeCommand="[SystemFolder]cmd.exe /C app.exe" />

希望有所帮助。

雷 (Léi)

WiX 工具集文档有一个叫做“如何在安装后运行应用程序”的主题,介绍如何实现这一点。

请查看WiX和DTF:使用启动程序在Vista中强制提升权限运行整个msi文件

您可以通过GenerateBootstrapper任务在.wixproj文件中自动化此操作。总之:

建立机构。 表明这一点:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="Setup" type="win32" />
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

并按照以下方式修改您的.wixproj文件:

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 <!-- standard PropertyGroups and ItemGroups -->

 <PropertyGroup>
   <WindowsSDK>$(registry:HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SDKsWindows@CurrentInstallFolder)</WindowsSDK>
 </PropertyGroup>
 <PropertyGroup Condition="$(WindowsSDK) ==   ">
   <WindowsSDK>$(registry:HKEY_CURRENT_USERSOFTWAREMicrosoftMicrosoft SDKsWindows@CurrentInstallFolder)</WindowsSDK>
 </PropertyGroup>

 <PropertyGroup>
   <mt_exe>$(WindowsSDK)binmt.exe</mt_exe>
 </PropertyGroup>

 <ItemGroup>
   <BootstrapperFile Include="Microsoft.Windows.Installer.3.1" >
     <ProductName>Windows Installer 3.1</ProductName>
   </BootstrapperFile>
   <!-- more BootstrapperFile items -->
 </ItemGroup>

 <Target Name="Bootstrapper"
         Inputs="$(OutDir)$(TargetFileName)"
         Outputs="$(OutDir)Setup.exe"
         Condition="  $(OutputType) == package  " >
   <GenerateBootstrapper ApplicationName="application name"
                         ApplicationFile="$(TargetFileName)"
                         BootstrapperItems="@(BootstrapperFile)"
                         ComponentsLocation="Relative"
                         OutputPath="$(OutputPath)"
                         Culture="en-US"
                         Path="$(WindowsSDK)Bootstrapper" />
 </Target>

 <Target Name="PatchSetupExe" DependsOnTargets="Bootstrapper">
   <Exec Command= "$(mt_exe)" -manifest setup.manifest -outputresource:$(OutDir)Setup.exe;#1  IgnoreExitCode= false  />
 </Target>

 <Import Project="$(MSBuildExtensionsPath)MicrosoftWiXv3.0Wix.targets" />

 <PropertyGroup>
   <BuildDependsOn>$(BuildDependsOn);Bootstrapper;PatchSetupExe</BuildDependsOn>
 </PropertyGroup>
</Project>

现在每次构建将生成一个正确的Setup.exe,可以以提升的身份运行。





相关问题
3rd party Wix libraries

I am just getting started with Wix. I see there there a several libraries included with the default Wix install. I also see that users can create their own libraries(wixlibs). Are there any 3rd ...

Psake, Powershell & Wix

I have the below function as a part of my psake build. When the build is executing Candle.exe throws this error: candle.exe : warning CNDL1098: ext .BuildPackagesWixWebinWixIIsExtension.dll ...

wix custom dialog for config edit

hi i m trying make a setup msi for my application with wix v3 I have a problem about this task; I need a user input that will be stored in my application s config file (for example i need a dialog for ...

Closing an application using WiX

In creating my WiX installer I have run into an issue when trying to close an application before installing the upgrade. Below is an example of how I am attempting to do this. <util:...

Conditional uninstall of previous version in Wix

I m doing an installer for an software used for debugging embedded ARM cores (OpenOCD) and this installer automatically removes the previous versions - that s simple. However, sometimes that would be ...

热门标签