I am trying to build a .NET MAUI App for Windows platform which requires admin permissions for working. For launching the app in admin, I added the following lines to the app.manifest
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
This launches the app in admin mode fine, but in the app, I have a button that launches the FilePicker.PickAsync
. This works in non admin mode, but when I start the debug mode in admin, the app just closes, no crash, the mode in Visual Studio remains Debug, no breakpoint hit.
What could the issue be?
Alternatively, I want to launch a process in admin mode and also get the output from it (so cannot use processStartInfo.UseShellExecute = true
and processStartInfo.Verb = "runas";
). I want to make it generalized, so no hardcoded admin name and password. Is there a way to do this?