通过 Windows 10 uwp 上的代码重新启动 [英] restart via code on windows 10 uwp

查看:37
本文介绍了通过 Windows 10 uwp 上的代码重新启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们创建了一个 Windows 10 应用程序,可以在 Windows 10 自助服务终端模式的平板电脑上运行.它工作得很好,但是,由于位置非常偏远,wifi 连接有时会丢失.我们尝试从网络方面解决该问题,但是当设备丢失并重新获得互联网访问权限时,该应用程序仍会挂起,就好像它没有互联网访问权限一样显示空白页面.在使用这些设备的地方,它们用螺栓固定在墙上以防止盗窃.这意味着如果我们想重新启动它非常耗时,因为我们必须从墙上拧下外壳然后打开外壳才能访问电源按钮,而让应用程序再次成功运行的唯一方法是执行在设备上重新启动.

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.

有人建议我们有办法从应用程序重新启动,但是,我尝试过的每个代码示例都无法在 Windows 10 UWP 中运行.这是我发现的最常见的一种:

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");

我可以访问命名空间

System.Diagnostics

但 Process 类不存在.有人对通过 Win 10 UWP 上的代码重新启动有什么建议吗?或者更好的解决我们的问题?提前致谢.

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.

还值得一提的是,我也尝试过执行 Powershell 命令,但我需要为 Powershell 类引用的 dll 与 UWP 不兼容.

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.

推荐答案

UWP 应用可用的 API 无法满足您的需求.这是一个安全决定.通过商店分发的应用程序不应该能够执行诸如重启机器之类的操作.

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.

根据您的情况,虽然您不需要通过商店.这意味着您可以 PInvoke 本机代码来做任何您想做的事情.这仍需要在实际设备上启动.

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.

这篇关于通过 Windows 10 uwp 上的代码重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆