How to check in WiX, if user has admin rights? - wix

I have programmed a Bootstrapper application with WiX 3.8, which installs IIS Express 8.0 and activates IIS-features.
But the feature-activation only works, when the user is a local administrator at least.
How can i check in a WiX-Bootstrapper, if the user has admin rights?
Thanks in advance!

See:
Burn Built-in Variables
•Privileged - non-zero if the process could run elevated (on Vista+)
or is running as an Administrator (on WinXP).
This is similar to the Windows Installer Privileged property.
Also check that you are using the PerMachine attribute on the ExePackage element if you are using it.

Related

Run wix immediate custom action with elevated privileges

We are populating the IIS websites to a drop down list based on the instructions provided here: Bind IIS local websites in dropdown list of wix installation?
The custom action works when the msi is launched from admin command prompt, however there is a failure when the msi is launched with out admin rights. Having the Impersonate value to no in the CA does not elevate the custom action execution with administrator privileges.
Is there a way to launch the msi with administrator privileges? How to execute immediate custom action in UI sequence with elevated access rights?
Thanks.
It's unfortunate that the IIS API (ServerManager class in .NET) requires elevation. What I do in this situation is create a bootstrapper for the MSI and mark it to require elevation.
In order to resolve the issue of running the Immediate custom action with admin rights, we had to embed the msi into an exe and display the error message if exe is not run as administrator.
ChilKat Zip 2 Secure Exe creator software was used to create an exe. https://www.chilkatsoft.com/chilkatsfx.asp
Added the following snippet in wix project: <Condition Message="Launch installer with admin rights!">Privileged</Condition> in order to display error message if the it is run in non admin mode.

How to run WIX bootstrap built exe to run in silent mode?

Is it possible to run the exe built using WIX burn bootstrap to run in silent mode? I need to do this in order to skip the UAC prompt. Are there any better ways to skip the UAC prompt using the WIX project itself? Without making any changes to the registry keys manually.
Burn supports silent installations. Use the /quiet switch to run installation without any user interface. This will not show the UAC prompt.
AppInstaller.exe /install /quiet
If your installation requires elevated rights to install properly, run it from another already elevated process - either command line, or a management software.

Wix Installer: Error 1925 when using silent installer

In my wix setup, I use InstallScope="perMachine". In the interactive setup, there is no problem and it installs my application perfectly. However, when I try to install it from command line using /qn, I get the following error.
MSI (s) (60:EC) [11:51:05:268]: Product: ClickShare Launcher -- Error 1925. You do not have sufficient privileges to complete this installation for all users of the machine. Log on as administrator and then retry this installation.
Could anyone tell me why it gives such problem only in silent installation? Does command line have different user privileges?
Can I somehow detect if the user has required privileges and install the application perUser instead of perMachine? Would this be a solution?
Thanks.
You can try to set the install per user / per machine code as a parameter
C:\Users\xxxxx\Desktop>msiexec /i "program.msi" MSIINSTALLPERUSER=1 ALLUSERS=2 /qn
this helped us on a application that did NOT require admin priviledge on interactive, but did require admin priviledge on silent mode....
maybe it helps some other users in the future... (from google searches)
Starting with Windows Vista, MSI installs running from a standard user process requiring elevation cannot do so when running silent. This is due to UAC. Elevate the process prior to invoking msiexec.

About the failure in making MSI installer

I'm making a installer, a strange issue was on my way.
I use a custom action to call the sc.exe to install my service, and the MSI is already built.
But If i click the installer to install, the installation failed, the log says that the sc.exe installation failed.
But the wired thing is that if I use a CMD in administrator privilege and use msiexec to run the installer, it'll succeed.
Why?
In question itself you have answered your question.
Windows vista onward by default runs most applications with least privilege access (non-admin) in an attempt to keep both malicious virus code and inexperienced end users from damaging the system.As your application is trying to modify the system, it needs to be elevated to Admin privilege in order to run successfully.
Go through Services permissions.
To run your custom action with elevated privileges set Impersonate as No and Execute in custom action as deferred.deferred Indicates that the custom action runs in-script (possibly with elevated privileges).refer this for more info.
Let Me know if it worked for you

Can i launch a prerequisite as an admin on windows?

Im trying to create a per user installation for my program made in vb.net
I have .net 4 as a prerequisite which im going to download if its not installed
The problem ive run into is admin rights is there a way to install the framework as an admin/elevated user then install my application as the current user so basically
user launches bootstrapper -> pre-reqs run as admin -> application runs as current posibbly limted user.
Im making the installer for my application using Wix (3.5), then im using dotNetInstaller to bootstrap and deal with the prerequisites.
If an admin installs application from the limited users profile he takes over the installation, which is what I dont want, but if the .net isnt installed the admin has to do this.
The admin could install the pre-requesites then close the bootstrapper then the user could install the application but this doesnt seem like a great idea.
Appreciate any help/advice anyone can give.
I think if dotNetInstaller is run un-elevated, and you will start a pre-req which needs elevation, it will automatically show a UAC prompt. But the dotNetInstaller will remain un-elevated. So your installer will also run un-elevated.
See also Configuring dotNetInstaler 2.0 to install custom prerequisites and then run a custom exe with elevated privileges which explains how to run dotNetInstaller un-elevated.