1

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?

Shantanu Shinde
  • 932
  • 3
  • 23
  • 48

1 Answers1

0

This is the limit (or bug) in the native windows app. You can check the existed issue about Trying to use a FileOpenPicker while running the app as Administrator will crash the app on the github.

And you can follow up this issue or try the workaround which used the win32 api.

Liyun Zhang - MSFT
  • 8,271
  • 1
  • 2
  • 14