restart via code on windows 10 uwp

跟風遠走 提交于 2019-12-21 20:47:16

问题


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:


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.



来源:https://stackoverflow.com/questions/33634615/restart-via-code-on-windows-10-uwp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!