ClickOnce does not support the request execution level ‘requireAdministrator’

ClickOnce is a deployment tool that enables you to create self-updating Windows applications that can be installed and run with the tiniest user interaction. Visual Studio fully supports publishing and updating applications deployed with ClickOnce technology. Windows form applications might require elevated admin permissions based on application needs, and ClickOnce does not support the request execution level requireAdministrator. However, we have a workaround to fix this problem. This article describes how to achieve it.

1. Are you trying to publish Windows applications with ClickOnce security settings?
2. Are you required to run the Windows application using Administrator permissions?

Follow the below steps to fix the issue.

1. Remove elevated requireAdministrator permission from the application

To remove elevated requireAdministrator permission from the Windows application, change requestedExecutionLevel from requireAdministrator to asInvoker in app.manifest of the application. app.manifest should look like in the below image.

2. Check and acquire administrator permission to start of your application using the below methods

        static void Main()
        {   
         try
            {
                 AdminLauncher();
                //only admins can run this wizard
                if (IsAdmin())
                {
                    // your starting point of application. 
                }
            }
            catch (Exception ex)
            {
                // handle how do you want to react here..
            }
        }
        private static void AdminLauncher()
        {
            if (!IsAdmin())
            {
                ProcessStartInfo proc = new ProcessStartInfo();
                proc.UseShellExecute = true;
                proc.WorkingDirectory = Environment.CurrentDirectory;
                proc.FileName = Application.ExecutablePath;
                proc.Verb = "runas";
                try
                {
                    Process.Start(proc);
                }
                catch
                {
                    // If dont want to lauch application as admin or do not have permissions
                    return;
                }
                Environment.Exit(0); // Quit itself
            }
        }
        // check if application is lauched with admin permissions.
        private static bool IsAdmin()
        {
            WindowsIdentity id = WindowsIdentity.GetCurrent();
            WindowsPrincipal principal = new WindowsPrincipal(id);
            return principal.IsInRole(WindowsBuiltInRole.Administrator);
        }

You can now use ClickOnce security settings to publish your Windows application.

ClickOnce does not support the request execution level 'requireAdministrator'

Reference to this post – Stackoverflow

We have seen how to resolve ClickOnce does not support the request execution level ‘requireAdministrator’ error.

See more

Kunal Rathi

With over a decade of experience in data engineering and analytics, I've assisted countless clients in gaining valuable insights from their data. As a dedicated supporter of Data, Cloud and DevOps, I'm excited to connect with individuals who share my passion for this field. If my work resonates with you, we can talk and collaborate.
I am always interested in new challenges so if you need consulting help, reach me at kunalrathi55@gmail.com.

Shopping Cart
Scroll to Top