开发者

WIX: How to distinguish between members of the Administrators group and built-in Administrators

开发者 https://www.devze.com 2023-02-25 13:49 出处:网络
My installation should behave differently for admin and regular user (different installation directory etc). At the same time it should work for XP, Vista, and Windows 7.

My installation should behave differently for admin and regular user (different installation directory etc). At the same time it should work for XP, Vista, and Windows 7.

The installer works as I would expect for XP and Vista, yet it fails to detect admin user on Windows 7.

I set MSIUSEREALADMINDETECTION to 1 to be sure that Privileged is set only for admin users.

<Property Id="MSIUSEREALADMINDETECTION" Value="1" />

As admin user the following condition does not fail on Vista, yet it fails on Vista

<Condition Message="Not Privileged">Privileged</Condition>

Here is t开发者_StackOverflow中文版he test project (I know it's incomplete:)

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="0b241708-eb30-4bd9-9906-983f228ee2a6" Name="wixTest01" Language="1033" Version="1.0.0.0" Manufacturer="wixTest01" UpgradeCode="1093efb2-75d0-499a-8050-99adfc8ae7c2">
    <Package InstallerVersion="200" Compressed="yes" />

    <UI>
      <UIRef Id="WixUI_InstallDir" />
    </UI>

    <Property Id="MSIUSEREALADMINDETECTION" Value="1" />
    <Condition Message="Privileged">Privileged</Condition>

  </Product>
</Wix>

UPDATE:

I've just found this:

http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Admin-check-in-Win-2008-td4557002.html

I used built-in Administrator account on Vista and a created admin (members of the Administrators group) on Windows 7. I thought that these accounts are the same, yet they are not.

A built-in administrator has its property Privileged set to 1, while members of the Administrators group don't.

It seems that there is no way to detect a members of the Administrators group?


As described in the thread you link to, that's standard behavior when UAC is enabled. With the UAC consent prompt, members of the Administrators group get elevated permissions only on-demand; at other times, they're pretty much standard users (more or less).


Don't worry about setting MSIUSEREALADMINDETECTION, that's for the AdminUser property.

I use the following code:

<Condition Message="Privileged">
    <![CDATA[Installed OR Privileged]]>
</Condition>

However, as Vista and Windows 7 feature "over the shoulder" authentication (refer Using Windows Installer with UAC MSDN Documentation) the user doesn't have elevated Privileges during the InstallUISequence, you're going to run into issues.

For example, a standard user runs the installer and only once they hit the "Install" button (with the UAC shield) are they prompted for Administrative credentials so you don't know if an Administrator is going to provide them or not earlier on in the installation process.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号