How to add "shutdown" capabilitie to an UWP app

asked 2023-01-07T11:34:45.32+00:00
Richab 1 Reputation point

I'm newbie in UWP.
I want to write an UWP app that let user shutdown automatically the PC at a scheduled time choosen by the user.
I want to add the "shutdown" capability (package.appxmanifest) but i got this error:

error C00CE169: App manifest validation error: The app manifest must be valid as per schema: Line 36, Column 17, Reason: 'shutdown' violates enumeration constraint of 'internetClient internetClientServer privateNetworkClientServer

Thanks for any help.

Universal Windows Platform (UWP)
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,939 questions
{count} votes

1 answer

Sort by: Most helpful
  1. answered 2023-01-09T02:50:32.84+00:00
    Roy Li - MSFT 26,391 Reputation points Microsoft Employee


    Welcome to Microsoft Q&A!

    It seems that you are trying to use ShutdownManager Class to shut down your device. You need to add the systemManagement capability instead of shutdown . All the available capabilities are listed here: App capability declarations.

    If you need to add the systemManagement capability, the "iot" namespace needs to be added to the manifest of your UWP app first. Then add it to the IgnorableNamespaces list.

      IgnorableNamespaces="uap mp iot">  
        <Capability Name="internetClient" />  
        <iot:Capability Name="systemManagement"/>  

    As you could see, this capability belongs to IOT namespace. The shundown method in the ShutdownManager Class only applicable to IOT device, such as raspberry pie with iot specific OS. And it will not work for Windows 10 Pro tablet, if you do want to shut down device, we suggest you use desktop bridge to make desktop extension for uwp app and shut down computer with Win32 api Process.Start("shutdown", "/s /f /t 0");.

    Thank you.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    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.

    No comments