Launch application after installation complete, with UAC turned on

拟墨画扇 提交于 2019-11-29 03:01:03

问题


Good day.

I've been building an installer for our product using the WIX(Windows Installer XML) technology. The expected behavior is that the product is launched, if the check box is checked after installation.

This has been working for some time now, but we found out recently that UAC of Win 7, and Vista is stopping the application from launching. I've done some research and it has been suggested to me that I should add the attributes

Execute='deferred' and Impersonate='no'.

Which I did, but then found out that to execute deferred, the CustomAction has to be performed, between the InstallInitialize, and IntallFinalize phases; which is not what I need. I need the product to launch AFTER install finalize, IF the launch checkbox is checked. Is there any other way to elevate permissions?

Any and all answers, suggestions, or resonings will be appreciated.


回答1:


Unfortunately, the topic that Rob mentioned doesn't really help for Windows Vista or 7 as I have found. Especially with UAC turned on.

The way I have got around this is to use a CustomAction that launches the command prompt and launches the application you want.

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

Hope that helps.

Ray




回答2:


The WiX toolset documentation has a topic called How To: Run the Installed Application After Setup that covers how to do this.




回答3:


See WiX and DTF: Using a bootstrapper to force elevated privileges in Vista how you can run the whole msi elevated.

You can automate this in the .wixproj file with help of the GenerateBootstrapper task. To summarize:

Create a setup.manifest like this:

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

And modify your .wixproj file like this:

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

 <PropertyGroup>
   <WindowsSDK>$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows@CurrentInstallFolder)</WindowsSDK>
 </PropertyGroup>
 <PropertyGroup Condition="$(WindowsSDK) == ''">
   <WindowsSDK>$(registry:HKEY_CURRENT_USER\SOFTWARE\Microsoft\Microsoft SDKs\Windows@CurrentInstallFolder)</WindowsSDK>
 </PropertyGroup>

 <PropertyGroup>
   <mt_exe>$(WindowsSDK)bin\mt.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)\Microsoft\WiX\v3.0\Wix.targets" />

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

Now a correct setup.exe which will run elevated will be generated on every build.



来源:https://stackoverflow.com/questions/2282960/launch-application-after-installation-complete-with-uac-turned-on

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!