Bootstrapper to check admin rights in a system - wix

Is there any possibility where wix bootstrapper checks whether user has admin privileges so that admin-msi can be installed, if not a non admin-msi is installed.
basically how to provide install condition inside chain to check windows version and privilege property.
How to make major and minor upgrades for wix bootstrappers.

As far as I know, you do not let the Wix bootstrapper "check whether user has admin privileges", but you actually specify the admin rights for the Wix installer so it can perform the installation properly. You would do so by specifying the follow Package properties:
InstallPrivileges="elevated"
InstallScope="perMachine"
In terms of functionality, this means that a User Access Control window will appear asking the user to allow the Wix installer to proceed with the installation. If the user does not happen to have an administrator account (or an account with administrative rights, however you want to describe it), Windows would require the user to type a username and password of an account that does have administrative rights.
Have a look at the following StackOverflow answer.
Hope that helps you!

Related

Privileges for installing executables with nsis

I need to write an installer for some executables. The user might copy them wherever he wants but usually this is performed in C:\Program Files\MyProgram
If there's visual studio installed I also need to copy something to system32 (and that requires admin rights I suppose).
Does that make sense to support normal users and admin users? I mean: if I need to install something I always need admin rights, is this correct?
Supporting both can be tricky but it can be done by using RequestExecutionLevel highest and then checking if you actually are admin with the UserInfo plugin. You would then have to tell the user to force the installer to run as admin if they are not already when you detect VS.
A normal user cannot write to $programfiles so you have to default $instdir to $localappdata\Programs\Yourapp. You should also take a look at SetShellVarContext, it will help you with the HKCU vs HKLM issue...

WiX, UAC, managed custom action and impersonation

I have built a Windows Installer package using WiX 3.6 that embeds a custom managed (C#) action.
At this stage, the installation requires that
The installer be run using a specific local administrator account (in this case, the SharePoint installer account, which is a local administrator)
User Account Control be disabled
There really isn't a way I can bypass requirement #1, because the managed action can only perform certain steps if it runs in the context of the SharePoint installer account.
I would like to remove requirement #2 and let the installer properly run even if UAC is enabled.
I've researched the issue quite extensively but still can't get it to work. I have set InstallScope="perMachine" in my package, which seems to properly prompt for UAC elevation, but the installer still fails with the infamous 2869 error.
The main problem is that my custom action is configured with Impersonate="yes" because it has to run in the context of the current user, not the local administrator account. When I search online, almost all "fixes" point to Impersonate="no" in the custom action, but that's not an option for me.
My question therefore is: is there a way to run a custom managed action with the identity of the current user without requiring UAC to be completely disabled?
When you use Impersonate="yes" your Custom action runs without administrative privileges with the credentials of the currently logged user.
When Impersonate="no" your Custom action is run in System context. When running in system context, the custom action has full access to the system.
From WiX CustomAction element documentation, Impersonate attribute:
This attribute specifies whether the Windows Installer, which executes as LocalSystem, should impersonate the user context of the installing user when executing this custom action. Typically the value should be 'yes', except when the custom action needs elevated privileges to apply changes to the machine.
Where are you referencing the custom action?
Having the .msi running with elevated privileges might not be enough.
To be sure that your custom action works with elevated privileges you also have to use a deferred custom action and reference it in the InstallExecuteSequence. This might not solve your problems, but the articles linked at the bottom goes in detail in explaining the UAC logics during an msi installation.
Basically, not everything the installer does carries the privileges with it, an you have to be sure to run the custom action when the installer is using the elevated privileges.
Source: http://blogs.msdn.com/b/rflaming/archive/2006/09/30/uac-in-msi-notes-when-general-custom-action-mitigation-fails.aspx
I hope you find this information useful, I might be of more assistance if you share your custom action code.

Windows Installer with Administrator rights

I use Wix toolset 3.5 and am interested to know if there is any windows installer which installs only for the administrator?
There can be more than one user with administrative privileges, so I would install for all users and set up the application to require admin rights at start-up. One way to do that is with an application manifest:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb756929.aspx
MOreover, in addition to the answer of #Wim and comments, u can try to create a logic of ur installer based on WiX flag Privileged. it will help u to install some features (or even components) only for admin user (this flag check if the current user has admin rights). Usage of this flag is just simple:
<Component Id="" Guid="">Priveleged</Component>
and in this case component will install only when the current user has an admin rights. hope will help

WiX - Elevating (or reducing) privileges at install time

I am working on a project that has been using 2 VD projects to distribute admin and user versions of installations, and now I need to switch to WiX. It was a bit painful experience with lack of documentation and all, but I managed to make something of it.
However, there is still one problem: I want to make only one .msi which will allow user to choose whether he wants to install as admin or as user. If he chose user, I don't want to ask him for elevation (as he doesn't need it), also if he chose admin, I don't want the installation to crash but to ask for privileges.
My current solution crashes in admin mode if I set InstallPrivileges to limited because the user doesn't have the permission to install, and it prompts for elevation in user mode if I set it to elevated.
My opinion is that there is no way to fix this because of compatibility with MSI, but perhaps there is some way to change privileges from elevated to limited in install time that I'm missing.
In conclusion, I want to know these things:
Is it possible to change privileges at install time
If there is no way to do so, what is the best workaround for this problem (exporting 2 .msi files or something)
One solution is to build two separate installers and then launch them via a custom WiX bootstrapper (aka Burn). The bootstrapper would be in charge of displaying the UI and launching the appropriate .msi.
Or you could separate the "admin" features into a separate .msi and then use a custom bootstrapper to install both .msis if the user selects an admin install.

Installation change do not ask for UAC permissions

I implemented an installer for our product. Installer needs administrator privileges, so I used setup bootstrapper with a manifest file (as recommended here) to get these privileges on a Windows machines with UAC enabled. Installation and uninstall goes fine - the user is asked for permission and the installer does what it needs to do.
But if you run Control panel → Programs and Features and select "Change"* for installed program, an error occurs (custom, from installer LaunchConditions), telling that the installer needs administrative privileges. And I can't find any way to ask for permission in a such case - Windows simply runs the MSI file and doesn't know anything about required permissions.
Even more strange is the repair functionality - it asks for permission, but then fails to do some actions that were allowed during installation, using SetupBootstrapper.
I found a similar problem here:
But the proposed solutions are unacceptable in our case.
The only workaround for the change functionality now is to always use SetupBootstrapper and do not use the Programs and Features menu, but that is not very user-friendly and forces the user to keep the installer on his/her hard drive.
Has anybody better advise?
PS: I use WiX for creating the installer, so it would be great to hear about WiX solutions, but I'm pretty sure that it doesn't depend on the installer creation language, but only on MSI specifics.
What actions are failing? If they are actions that you added to the installation, make sure that such actions are defined with Impersonate="no" and Execute="deferred" (or "commit" or "rollback") and that they are sequenced somewhere between InstallInitialize and InstallFinalize.