You update the manifest
https://blog.verslu.is/maui/net-maui-windows-app-as-administrator-elevated/
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
How I run maui app on windows 8 as admin after deployment as unpcakaged (exe).
This deployment command.
dotnet publish -f net8.0-windows10.0.19041.0 -c Release /p:AppxPackageSigningEnabled=true /p:PackageCertificateThumbprint="c01ba45666762f3615cf6813aeb4dc4b1919541d" -p:RuntimeIdentifierOverride=win10-x64
I do not want to set on exe properties / compability to run as administrator.
Please supply all steps for that.
Thanks in davance,
Update:
1.what the user will see when he click on exe?
2.does in shortcut combalty mode i will see run as admin?
3.it mention that this will on certain windows ,sdk 1.1 and above, is it a real problem fir the app?
I set it to administrator .After publish the exe icon is with icon of admin. But i do not see any popup of require of admin acknoledge when clicking on it.
This comment has been deleted due to a violation of our Code of Conduct. The comment was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
You update the manifest
https://blog.verslu.is/maui/net-maui-windows-app-as-administrator-elevated/
1.what the user will see when he click on exe?2.does in shortcut combalty mode i will see run as admin? 3.it mention that this will on certain windows ,sdk 1.1 and above, is it a real problem fir the app?
The app will popup an alert asking for admin permission. If the user has admin permissions it will ask for acknowledgement, if the does not, it will ask for the administrator login information.
I have installsheild that create installtion for maui app that publish as exe. It create also shortcut on desktop. It possible to make something in maui app to set automatic the properties/compability/set administrator checkbox as admin?
Your quick answer will be appreciated
Do i need to set it as invoker ?
......
I used this code:
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
+And
<Capabilities>
<rescap:Capability Name="runFullTrust" />
<rescap:Capability Name="allowElevation" />
</Capabilities>
But is not work!!!! the shorcut is not mark as run as admin in compabilty tab
I have installsheild that create installtion for maui app that publish as exe. It create also shortcut on desktop. It possible to make something in maui app to set automatic the properties/compability/set administrator checkbox as admin?
Could you please explain more about this requirement? Do you want the user to be able to manually change the compability after the Maui app is launched? If so, this is not possible. The compability is a list preset by the developer and it will be integrated into the application after compilation and cannot be changed.
Do i need to set it as invoker ?
If you need to set the default behavior to start as an administrator, you don't need to set this. In fact, asinvoker
is the default setting for Maui programs. It will automatically switch the corresponding startup mode according to the user identity of the application: user/guest/administrator
.
If you need to run as an administrator by default, please refer to the documentation provided by Bruce to set it.
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
I set it to administrator .After publish the exe icon is with icon of admin. But i do not see any popup of require of admin acknoledge when clicking on it.
When I debugthe app throgh VS I cant do it. only when I change it to
level="asinvoker" why ?
I set it to administrator .After publish the exe icon is with icon of admin. But i do not see any popup of require of admin acknoledge when clicking on it.
Have you followed this blog to set it up? In addition, if your Windows default user is admin, there will be no pop-up window when you start the program.
Yes i followed.what about debug issue?
.......
Why i can debug my app? Can you please answer?
Thanks for your feedback.
Could you please provide the following information, and update into your question?
For elevated privileges, you don't need to manipulate appx.manifest
, please refer to Tasks Requiring Higher Privileges to modify the trustinfo
.
In addition, the compatibility tab is to override defaults to make an app work that wasn’t written to modern standards. If you define the app itself to require admin then it doesn’t need a compatibility override.
Your quick answer will be appreciated.
Your qucik answer will be appreciated.
and second row allow elvation
Do you mean you added the Capabilities directly to the app.manifest
?
The Capabilities property needs to be updated in the package.appxmanifest file instead of the app.manifest. Please refer to the Updating the package.appxmanifest.
The solution to run your app elevated is mainly two steps: update the
package.appxmanifest
and update theapp.manifest
. In a .NET MAUI app you can find those underPlatforms\Windows
. Let’s start with the first one. Open it up with a text editor and find theCapabilities
node. Make sure that it looks somewhat like underneath
After following the steps in this blog, the program behaves the same after debugging and publishing in Visual Studio.
ו did it, but the debugging is not working.
Could you please provide the exact steps that can reproduce this issue and update it in the question?
I did exactly what wriiten in the Bruce's post. But debugging is not working.
Why debugging is not working?is ut work in your side?
I tested it on Windows 10 and 11, and the app would pop up a window asking for administrator privileges both in debug mode and after release.