For an F# application, I attempted to follow these instructions:
How to force my .NET application to run as administrator?
Alas, Visual Studio does not have the same commands and project configuration pages for F# projects as for C# projects. I have created a throwaway C# project, copied its app.manifest
into my F# project, and modified the <requestedExecutionLevel>
as per the issue above. Nevertheless, the .exe
still runs without administrator privileges.
So then, how do I build an F# application so that it only runs as administrator?
Method 1. Toggle the Fn Lock key All you have to do is look on your keyboard and search for any key with a padlock symbol on it. Once you've located this key, press the Fn key and the Fn Lock key at the same time. Now, you'll be able to use your Fn keys without having to press the Fn key to perform functions.
To enable FN Lock on the All in One Media Keyboard, press the FN key, and the Caps Lock key at the same time. To disable FN Lock, press the FN key, and the Caps Lock key at the same time again.
C# project files (.csproj
) contain the following lines:
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
I just copied and pasted those lines into my .fsproj
file just above the following line:
<Import Project="$(FSharpTargetsPath)" />
... and lo, my .exe
now has the little shield badge on its icon and prompts me for elevated privileges every time I run it.
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