Home
About
Contact
Monday, October 06, 2008

This is my third post in my WiX and DTF series for WiX 3.0. Here are some others I’ve written:

Normally bootstrappers are used for adding prerequisites to your installation; like the .Net Framework, Windows Installer etc. You can also use it for other purposes though. Basically it's an exe file with the msi (and any other installers) embedded. For the WiX series I'm currently doing we need this because:

  1. Use as workaround for the WiX bug in IIS extension where the installer fails because of missing privileges on Vista SP1.
  2. We want to do IIS custom actions in InstallUISequence which require elevated privileges which I will cover in a later post (hopefully very soon!).

I briefly mentioned InstallUISequence above. Windows Installer have several sequences, for details you can check them out here, but I'm just going to shortly explain two of them now. The InstallUISequence is the wizard part in the installer, InstallExecuteSequence is where things are happening and files are getting installed (when you click "Install" in the wizard).

Here's a bit of background. In Vista msi files does not run elevated (as admin) when you start them directly (double click on the msi). To do that you need to open an elevated command prompt and run the msi with msiexec /i yourInstaller.msi. That's not a good solution.

Normally there should be no need for admin privileges in UISequence (it's a reason it's not permitted per default), but there are exceptions, like the above. At least from my perspective. If you have a better way of solving this, I'm very interested.

So, with a bootstrapper or exe file you can do a bit more. For instance you can use mt.exe to add a manifest to he exe defining which privileges it requires to run. In this article I will describe how you can accomplish this using WiX and .Net.

Here's how to go about it:

  1. Copy Setup.exe found in the WiX bin folder to your project location (so we don't modify the original)
  2. Create a manifest file (e.g. Vista.manifest) in your favorite text editor by adding this xml:
    <?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>
  3. Add the manifest to Setup.exe by using mt.exe found in the .Net SDK:

    mt.exe -manifest [pathToYourProject\]Vista.manifest -outputresource:[pathToYourProject\]Setup.exe;#1

  4. Use setupbld.exe found in the WiX bin folder to embed the msi installer into a exe like this:

    setupbld.exe" -out Setup.exe -msu MyMsi.msi -setup Setup.exe

    or even better, add it as a post-build event (Right click your project -> Properties -> Build Event -> Post-build Event Command Line):

    "C:\Program Files\Windows Installer XML v3\bin\setupbld.exe" -out $(TargetDir)Setup.exe -msu "$(TargetPath)" -setup "$(ProjectDir)setup.exe"

The interesting thing to note about the manifest file is this:

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

When setting the level to requireAdministrator Vista will show a UAC prompt when executing this file. The default level is asInvoker, which will run the exe with the current users privileges, but then the exe would have the same behavior as the msi.

Also note the assemblyIdentity node where you can set the actual version number of your installer and the name (if you use something else than Setup.exe).

.Net | Deployment | Security | Vista | WiX
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Live Comment Preview
RSS RSS - Comments Twitter LinkedIn
         
SEARCH
 
 
         
TOP POSTS
   
         
NAVIGATION
   
         
CATEGORIES
  .Net (42) Agile (22) Ajax (5) Architecture (3) Blogging (11) Books (1) BPEL (1) CloudComputing (3) CSharp (6) DasBlog (5) Database (2) DDD (1) Deployment (12) DSL (1) Events (26) ExtremeProgramming (3) Fun (5) Gadgets (3) IIS (6) Java (1) Linq (2) MemoryLeaks (5) Microsoft (35) NDC (2) NNUG (26) Other (8) Patterns (3) Performance (1) Scrum (13) Security (2) Silverlight (4) Software (18) TeamManagement (8) TechEd (7) Testing (4) Tools (20) TvGuide (1) Vista (15) VisualStudio (15) WCF (7) Web (12) Windows (6) WiX (6) Work (13) Workflow (3)  
         
ARCHIVE
   
         
BLOGROLL
   
         
ON THIS PAGE...