I have a dotnet console application that requires administrator privileges to run. I can't find how to do this. In a regular project I would add a app.manifest and set
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
but I can't figure how to embed this in the build.
How do I do this?
Right click your executable, go to Properties > Compatibility and check the 'Run this program as admin' box.
On the Windows desktop, right-click the Visual Studio shortcut, and then select Properties. Select the Advanced button, and then select the Run as administrator check box. Select OK, and then select OK again.
I found the simplest workaround would be to add the app.manifest file with the setting like what in net framework app
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
then on your net core project file (.csproj in C# project) add the following:
<PropertyGroup> <ApplicationManifest>app.manifest</ApplicationManifest> </PropertyGroup>
*Worked in Console and WPF netcore 3.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With