question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

There is no way to make an application to run as admin by default

See original GitHub issue

I’m trying to get an always-admin executable with .net Core. I’m new to this, so please bear with me.


The “published” executable doesn’t contain the application manifest I specified in the csproj file, instead that manifest is embedded in the DLL. This means that there is no way to always request elevation via UAC prompt.

This has been checked with the following commands executed in a WSL console:

Command: strings ConsoleApp1.exe | grep requestedExecutionLevel Output: <requestedExecutionLevel level='asInvoker' uiAccess='false' /> Command: strings ConsoleApp1.dll | grep requestedExecutionLevel Output: <requestedExecutionLevel level='requireAdministrator' uiAccess='false' />

Reproduced with:

Build command: dotnet publish -r win10-x64

C# code:

static bool isAdmin()
{
        return new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
}

.csproj contents:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <ApplicationManifest>app1.manifest</ApplicationManifest>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="System.Security.Principal.Windows" Version="4.4.0" />
  </ItemGroup>
</Project>

Environment data:

dotnet --info output:

Click to expand
Herramientas de la línea de comandos .NET (2.0.0)

Product Information:
 Version:            2.0.0
 Commit SHA-1 hash:  cdcd1928c9

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.15063
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.0.0\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Genboxcommented, Jan 1, 2018

+1 this is a pretty important feature.

0reactions
augustoproietecommented, Jul 30, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Run App as Administrator by Default in Windows 11
1. When you've located the file, right-click it to open its context menu. Then, select "Properties." 2. Navigate to the "Compatibility" tab. ......
Read more >
Run applications as administrator by default in Windows 10
Log In As Administrator · Go To Run ( WinKey + R ) · Type "secpol.msc" · Go To Local Polices > Security...
Read more >
Is there a way to set a program to always run as admin (not ...
* 1. Create a normal Short-Cut to application.exe on the desktop. 2. Right-click the short-cut and select Properties. 3. In ...
Read more >
Always run a program in administrator mode in Windows 10
Step 1: Open the Start menu and click All apps. Find the program you want to always run in administrator mode and right-click...
Read more >
How to Always Run a Program as Administrator in ...
Press Start, type the name of your app, right-click it, and press “Open file location” · Right-click your app's shortcut and choose “Properties”....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found