How to claims admin permission in wpf for app store

振宁 梁 21 Reputation points
2022-11-17T10:48:57.683+00:00

The app needs admin permission to be launched properly. In app.manifest, set requireAdministrator.
Feedback run errors after submission.
The product crashes at launch with error message "The request is not supported."
How should I set permissions?

XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
760 questions
{count} votes

Accepted answer
  1. Hui Liu-MSFT 37,946 Reputation points Microsoft Vendor
    2022-11-18T06:09:10.57+00:00

    You could try to make the WPF application to Run in Administrator Mode and then published it.

    1. Open the Solution Explorer

    2.Right CLick on the solution--->Add---->New Item---->App.Manifest---->OK
    3. Edit the Manifest file as follows:

    <requestedExecutionLevel level="asInvoker" uiAccess="false" />  
    

    (TO)

     <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />  
    

    4.After editing the Manifest file, Goto Solution project(RightCLick)------>properties------->Security

    Turn out the Checkbox of "Enable ClickOnce Security Settings"

    Run the Application, and Take setup, Now the application with Run as Administrator mode is achieved.

    Complete code:

     <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">  
       <security>  
         <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">  
           <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />  
         </requestedPrivileges>  
       </security>  
     </trustInfo>  
    

    Add the app.manifest file to project, and then ensure the .csproj file contains

     <ApplicationManifest>app.manifest</ApplicationManifest>  
    

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Blake Pell 0 Reputation points
    2024-01-02T22:58:44.9233333+00:00

    For posterity:

    Hui Liu-MSFT provided most of the answer but there's more.

    In order to fix this your Package.appxmanifest file needs to have the correct capabilities in it (you can't set them via the UI). In particular in the Capabilities section you'll need these two:

    <Capabilities>     
        <rescap:Capability Name="runFullTrust" />
        <rescap:Capability Name="allowElevation" />
    </Capabilities>			
    

    I was receiveing the same error as you when I only had "runFullTrust". I additionally had to add "allowElevation". That should do the trick for you.

    If you're submitting to the Windows Store you'll want to note to the reviewers in the testing steps why you're requesting elevation.

    Hope this helps (someone).

    0 comments No comments