0

I have UWP application running at kiosk mode in Tablet with Window 10. I would like to restart Tablet from my app. My installed UWP SDK version is - 10.0.18362.0. So I added into manifest:

<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" />
     <!-- Add the capability here -->
     <iot:Capability Name="systemManagement" />
     <DeviceCapability Name="wifiControl" />
     <DeviceCapability Name="bluetooth" />

And try to restart system in button event handler:

    private async void OnClick(object sender, RoutedEventArgs e)
    {
        await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
        {
            ShutdownManager.BeginShutdown(ShutdownKind.Restart, TimeSpan.FromSeconds(3));
        });
    }

And I get the error:

System.UnauthorizedAccessException - (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

There is my extensions:

enter image description here

I couldn't find Windows IoT Extension there. Maybe this is the reason? How can I restart my tablet programmably.

UPD: I installed SDK with IoT Extension and added reference it does't help.

1 Answer 1

1

I’m afraid your tablet doesn’t support this operation you want to achieve. This API only supports Windows IOT devices. It applies to the device with Windows IOT system.

4
  • Maybe I should use System.Diagnostics.Process.Start()?
    – JDo
    Commented Feb 18, 2021 at 12:27
  • 1
    you can include a companion Win32 app with your package and launch it with FullTrustProcessLauncher. You'll probably need elevation too, if you're going to reboot the system. Here's a walkthrough Commented Feb 18, 2021 at 13:52
  • 1
    UWP applications are sandboxed, you can’t launch other processes directly through Process.Start(). You could try to use Brokered Windows Runtime Components for side-loaded Windows Store apps to achieve it. then UWP app can call Win32 API hosted in a different process.
    – dear_vv
    Commented Feb 19, 2021 at 6:09
  • Please refer to the reply, then replace new ProcessStartInfo("shutdown", "/s /t 0") with new ProcessStartInfo("shutdown", "/r /t 0") to achieve restart .
    – dear_vv
    Commented Feb 19, 2021 at 6:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.