WIX bootstrapper application (BA) can easily determine if it runs as admin with the following code:
using System; using System.Diagnostics; using System.Security.Principal; static bool IsAdmin() { WindowsIdentity id = WindowsIdentity.GetCurrent(); WindowsPrincipal principal = new WindowsPrincipal(id); return principal.IsInRole(WindowsBuiltInRole.Administrator); }
and if it does not, run a new instance as admin and exit:
static void RunAsAdmin() { ProcessStartInfo proc = new ProcessStartInfo { UseShellExecute = true, WorkingDirectory = Environment.CurrentDirectory, FileName = Process.GetCurrentProcess().MainModule.FileName, Verb = "runas" }; Process.Start(proc); }