How to add "shutdown" capabilitie to an UWP app

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

Hi,
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.
Richab

Universal Windows Platform (UWP)
C#
C#
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.
11,297 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Roy Li - MSFT 33,931 Reputation points Microsoft Vendor
    2023-01-09T02:50:32.84+00:00

    Hello,

    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.

    <Package  
      xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"  
      xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"  
      xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"  
      xmlns:iot="http://schemas.microsoft.com/appx/manifest/iot/windows10"  
      IgnorableNamespaces="uap mp iot">  
      
      <Capabilities>  
        <Capability Name="internetClient" />  
        <iot:Capability Name="systemManagement"/>  
      </Capabilities>  
    </Package>  
    

    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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.