2

We've created a Windows 10 application that runs on tablets in Windows 10 kiosk mode. It works just fine, however, the wifi connection gets lost sometimes since the locations are very remote. We tried fixing the issue from the networking side, but when the devices lose and regain internet access the application will still hang as if it doesn't have internet access displaying a blank page. Where these devices are used, they are bolted into the wall to prevent theft. Which means if we want to reboot its very time consuming as we have to unscrew the cases off the wall and then open the cases to gain access to the power button, and the only way to get the application to run successfully again is to do a reboot on the device.

It was suggested that we have a way to perform a reboot from the application, however, every code example I've tried doesn't work in Windows 10 UWP. Here is the most common one I've found:

System.Diagnostics.Process.Start("restart", "/r");

I have access to the namespace

System.Diagnostics

but the Process class does not exist. Anyone have suggestions on rebooting via code on Win 10 UWP? Or a better solution to our issue? Thanks in advance.

It's also worth mentioning I tried execute a Powershell command too and the dll I need to reference for the Powershell class is not compatible with UWP.

  • 1
    Not possible. I'd suggest to hunt the bug which makes the restarts necessary firsthand or use a non-UWP app. – sibbl Nov 10 '15 at 16:47
  • Look for alternative solutions other than rebooting that perhaps the Win 10 sandbox will allow, e.g. Perhaps power-cycling Flight Mode to fix, or somehow triggering network connection to clear, then maybe you can code these options. – Muster Station Nov 10 '15 at 19:45
  • Thank you both for the replies, I'll look into your suggestions. – christina.snyder Nov 10 '15 at 19:51

2 Answers2

4

What you require is not possible with the APIs available to UWP apps. This was a security decision. An app distributed through the store shouldn't be able to do things like restart machines.

Based on your scenario though you shouldn't need to go through the store. This means that you could PInvoke native code to do whatever you want. This would still need to be initiated on the actual device.

Matt Lacey
  • 65,560
  • 11
  • 91
  • 143
  • You're correct, I'm sideloading the application and not publishing it to the store. Thanks for the help! – christina.snyder Nov 10 '15 at 19:50
  • Does sideloading enable calling APIs that would otherwise be restricted? My understanding was that sideloading merely emulates a Windows Store deployment and thus I assumed would be subject to the same security limitations. Is this not the case? – devios1 Oct 01 '16 at 00:01
  • 1
    @devios If sideloading it doesn't go through the checks the store does to make sure you're not using something you shouldn't. – Matt Lacey Oct 11 '16 at 15:45
0

Yes you can do that! You should add IoT System Administration in App capability declarations:

<Capabilities><iot:Capability Name="systemManagement"/></Capabilities>

and also You need to have "Windows IoT Extension for UWP" added to your project

using this for Shutdown

Windows.System.ShutdownManager.BeginShutdown(Windows.System.ShutdownKind.Shutdown, TimeSpan.FromSeconds(1));        //Delay is not relevant to shutdown

or for Restart

Windows.System.ShutdownManager.BeginShutdown(Windows.System.ShutdownKind.Restart, TimeSpan.FromSeconds(1));     //Delay before restart after shutdown

You can get more information in this Link

Faraz
  • 834
  • 1
  • 6
  • 14