+ Reply to Thread
Results 1 to 2 of 2

Thread: Run APP as ADMIN

  1. #1

    Run APP as ADMIN

    I had issue with windows 7 is sometimes user need to run my app as admin so that some functions could work like registry editing.

    Is there any idea i could run my app as admin even if user run it normally ?
    Last edited by csharpmaster; 11-11-2012 at 10:49 AM.

  2. #2
    Junior Member
    Join Date
    Jun 2012
    To check if APP is running as Admin or not :
            public Form1()
            private void GetAndDisplayRights()
                WindowsPrincipal pricipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
                bool hasAdministrativeRight = pricipal.IsInRole(WindowsBuiltInRole.Administrator);
                if (hasAdministrativeRight)
                    MessageBox.Show("RUNNING AS ADMIN");
    To RUN any application with administrative rights :
            private void RunElevated(string fileName)
                ProcessStartInfo psi = new ProcessStartInfo();
                //psi.WindowStyle = ProcessWindowStyle.Hidden; //remove the //s if you want to run the application hidden
                psi.Verb = "runas";
                psi.FileName = fileName;
                    Process p = Process.Start(processInfo);
                catch (Win32Exception)
                    //Do nothing. Probably the user canceled the UAC window

+ Reply to Thread

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts