0
votes

I have an msi that I created with WiX. I have no need to create a chain bundle, but I do need the ability to have the user right-click on the installer and choose "Run as administrator". You can't do that with an MSI in Windows, only with EXE's.

Is there a way to create a bootstrapper exe that has no UI of its own that will just kick off my msi?

Here's why I think need to do this (in case there's another solution out there):

My WiX installer installs a certificate using the following code:

<iis:Certificate Id="ClientCert"
                                     Name="MyClientCert"
                                     StoreName="personal"
                                     StoreLocation="localMachine"
                                     Request="no"
                                     Overwrite="yes"
                                     BinaryKey="ClientCertBinary"
                                     PFXPassword="mypassword"/>

When I run this on some computers while log in as admin, the certificate installs fine. But when I run it on some other computers, also while logged into an admin account, the install fails with the following error:

InstallCertificates:  Error 0x80090010: Failed to open PFX file.
InstallCertificates:  Error 0x80090010: Failed to get SHA1 hash of certificate.
InstallCertificates:  Error 0x80090010: Failed to resolve certificate: MyClientCert

I read on another post that the UAC sometimes behaves differently in regards to this. The person recommended right-clicking and picking "Run as administrator". I tried this by opening a command window as admin and running the msi and it worked like a charm. But opening a command window is not an option for when we release the msi to our customers. Hence the need for an exe bootstrapper.

1
Is there any specific reason you want "Run as Administrator" as a right click functionality? Why dont you run that from command prompt as a administrator?r_batra
Installing a "personal" certificate in the localMachine store works sometimes when logged in as admin and sometimes it doesn't. According to my research, it's because the UAC can be configured or behave differently on different computers. Because our customers will be running this, telling them (who are not likely to be tech savvy) to open a command window as admin is not an option.Brad Y.
Once I found how to do it, but only with C# custom bootstrapper. If it's ok for you, I can try to find that solution. P.S. It's possible and maybe easier to do it with C++ too.ba-a-aton
@ba-a-aton That sounds great! I've done some digging, but everyone just talks about Wix burn bootstrapper, which is overkill for my needs.Brad Y.
I'll try to find it, but it will take a time(( and I'm not sure that it will be succeessful. For now, please, see these posts - manual, Stackoverflow post and presentationba-a-aton

1 Answers

-1
votes

This is not really the answer to your question but you can have the right-click "run as administrator" option for a MSI file, by adding these registry keys :

  • add the option without admin rights, in the HKCU hive :

      Windows Registry Editor Version 5.00
    
      [HKEY_CURRENT_USER\SOFTWARE\Classes\Msi.Package\shell\RunAs]
      "HasLUAShield"=""
    
      [HKEY_CURRENT_USER\SOFTWARE\Classes\Msi.Package\shell\RunAs\Command]
      @="\"C:\\Windows\\System32\\msiexec.exe\" /i \"%1\" %*"
    
  • add the option with admin rights :

      Windows Registry Editor Version 5.00
    
      [HKEY_CLASSES_ROOT\Msi.Package\shell\RunAs]
      "HasLUAShield"=""
    
      [HKEY_CLASSES_ROOT\Msi.Package\shell\RunAs\Command]
      @="\"C:\\Windows\\System32\\msiexec.exe\" /i \"%1\" %*"