Victor Haydin
Victor Haydin

Reputation: 3548

How to run ngen from WiX with elevated rights?

I am trying to include ngen to my installer using this article. I want to run ngen synchronously (with priority=0) during installation, but it requires administrative rights to run. So, now I have following message in the log:

MSI (s) (74:2C) [18:30:14:310]: Invoking remote custom action. DLL: C:\windows\Installer\MSI60B0.tmp, Entrypoint: ExecNetFx
ExecNetFx:  Microsoft (R) CLR Native Image Generator - Version 4.0.30319.1
ExecNetFx:  Copyright (c) Microsoft Corporation.  All rights reserved.
ExecNetFx:  Installing assembly C:\myapp\myapp.exe
ExecNetFx:  Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
ExecNetFx:  Administrator permissions are needed to use the selected options.  Use an administrator command prompt to complete these tasks.
ExecNetFx:  Error 0xffffffff: Command line returned an error.
ExecNetFx:  failed to execute Ngen command (with error 0xffffffff): C:\windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe install "C:\myapp\myapp.exe", continuing anyway
ExecNetFx:  Microsoft (R) CLR Native Image Generator - Version 4.0.30319.1
ExecNetFx:  Copyright (c) Microsoft Corporation.  All rights reserved.
ExecNetFx:  Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
ExecNetFx:  Administrator permissions are needed to use the selected options.  Use an administrator command prompt to complete these tasks.
ExecNetFx:  Error 0xffffffff: Command line returned an error.
ExecNetFx:  failed to execute Ngen command (with error 0xffffffff): C:\windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe update /queue, continuing anyway

Is there simple way to ask user for administrative rights (using standard UAC prompt) at this moment, when ngen is starting? If user press "No", I want to proceed without ngen. If yes - run ngen and precompile my application. Any thoughts?

Thanks.

Upvotes: 1

Views: 1093

Answers (1)

Bob Arnson
Bob Arnson

Reputation: 21886

WiX already runs the NGen custom actions elevated (Execute="deferred" Impersonate="no"). Your .msi package must be per-machine to be able to run them.

Upvotes: 2

Related Questions