Christian Froehlich wrote:
> 
> Hi All,
> 
> I have hit a conundrum here. I have an immediate custom action that gets a
> list 
> of IIS application pools to be displayed in a ComboBox for user selection.
> 
> Now as this needs to be executed before the user interface is shown, i
> have made 
> this an immediate custom action. This seems to work fine for IIS 5.1/6.
> Today i tested this with IIS7 but to my dismay, it requires elevated
> privileges, 
> something that cannot be done with an immediate action.
> 
> The solution then is to make it a deferred custom action, however i am
> given to 
> understand that these can only be scheduled to run in the 
> InstallExecuteSequence?
> If that is indeed the case, how can i create a custom action that can run
> before 
> the UI and use elevated privileges?
> Or is there a better way to get a list of application pools that does not 
> require administrative access?
> 
> For your information my custom action is written in C# and uses a
> DirectoryEntry 
> to query the IIS metabase.
> 
> Any help that could be given would be greatly appreciated.
> 
> Many thanks,
> 
> Christian Froehlich
> 
> 
>       
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by 
> 
> Make an app they can't live without
> Enter the BlackBerry Developer Challenge
> http://p.sf.net/sfu/RIM-dev2dev 
> _______________________________________________
> WiX-users mailing list
> WiX-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wix-users
> 

Hi,

I realise this might be a bit late for you, but this problem has been
frustrating me all morning, so I thought I'd suggest my solution. 
I didn't really want a bootstrapper, because of the ARP issues. So, instead
I stuck this code at the top of my custom action to re-run the installer
with the appropriate privileges. It's not entirely elegant, but it seems to
do the trick with fresh installs and from ARP, and I haven't found any
issues with it so far.

WindowsPrincipal pricipal = new
WindowsPrincipal(WindowsIdentity.GetCurrent());
bool hasAdministrativeRight =
pricipal.IsInRole(WindowsBuiltInRole.Administrator);

if (!hasAdministrativeRight)
{
        if (MessageBox.Show("This installer requires administrator
privileges.\r\n\r\nDo you want to attempt to restart it with administrator
privileges?", "Administrator Privileges Required", MessageBoxButtons.YesNo,
MessageBoxIcon.Warning) == DialogResult.Yes)
        {
                ProcessStartInfo processInfo = new ProcessStartInfo();
                processInfo.Verb = "runas";
                processInfo.FileName = "msiexec";
                processInfo.Arguments = "/i " + session["OriginalDatabase"];
                try
                {
                        Process.Start(processInfo);
                }
                catch (Win32Exception)
                {
                        //Do nothing. Probably the user canceled the UAC window
                }
        }
        return ActionResult.UserExit;
}

Cheers,

Rich

-- 
View this message in context: 
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Custom-Actions-with-elevated-privledges-tp5435239p5748179.html
Sent from the wix-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to