2010-02-17 29 views
10

Ngày tốt lành.Khởi chạy ứng dụng sau khi cài đặt hoàn tất, với UAC đã bật

Tôi đã xây dựng trình cài đặt cho sản phẩm của mình bằng công nghệ WIX (Windows Installer XML). Hành vi mong đợi là sản phẩm được khởi chạy, nếu hộp kiểm được chọn sau khi cài đặt.

Tính năng này đã hoạt động được một thời gian, nhưng gần đây chúng tôi đã phát hiện ra rằng UAC của Win 7 và Vista đang ngừng ứng dụng khởi chạy. Tôi đã thực hiện một số nghiên cứu và tôi đã đề xuất rằng tôi nên thêm các thuộc tính

Thực thi = 'hoãn lại' và Mạo danh = 'không'.

Tôi đã làm, nhưng sau đó phát hiện ra rằng để thực hiện trì hoãn, CustomAction phải được thực hiện, giữa các giai đoạn InstallInitialize và IntallFinalize; đó không phải là những gì tôi cần. Tôi cần sản phẩm để khởi chạy sau khi cài đặt xong, nếu hộp kiểm khởi chạy được chọn. Có cách nào khác để nâng cấp quyền không?

Bất kỳ và tất cả câu trả lời, đề xuất hoặc cộng hưởng sẽ được đánh giá cao.

Trả lời

5

Thật không may, chủ đề mà Rob đề cập không thực sự hữu ích cho Windows Vista hoặc 7 như tôi đã tìm thấy. Đặc biệt là với UAC bật.

Cách tôi có được xung quanh việc này là sử dụng CustomAction khởi chạy lời nhắc lệnh và khởi chạy ứng dụng bạn muốn.

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

Hy vọng điều đó sẽ hữu ích.

Ray

2

Xem WiX and DTF: Using a bootstrapper to force elevated privileges in Vista cách bạn có thể chạy toàn bộ msi được nâng lên.

Bạn có thể tự động hóa điều này trong tệp .wixproj với trợ giúp của tác vụ GenerateBootstrapper. Để tóm tắt:

Tạo một setup.manifest như thế này:

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

Và sửa đổi tập tin .wixproj của bạn như thế này:

<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\[email protected])</WindowsSDK> 
</PropertyGroup> 
<PropertyGroup Condition="$(WindowsSDK) == ''"> 
    <WindowsSDK>$(registry:HKEY_CURRENT_USER\SOFTWARE\Microsoft\Microsoft SDKs\[email protected])</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> 

Bây giờ một setup.exe đúng mà sẽ chạy cao sẽ được tạo trên mọi bản dựng.

Các vấn đề liên quan