在UWP上通过ProcessLauncher更改系统时钟 [英] Change system clock by ProcessLauncher on uwp

查看:281
本文介绍了在UWP上通过ProcessLauncher更改系统时钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在树莓(uwp)上运行Powershell脚本,以通过c#更改系统时钟.

I'm trying to run a powershell script on raspberry (uwp) to change the system clock by c#.

运行下面的代码将引发异常"System.UnauthorizedAccessException".

Running the code below throw an exception 'System.UnauthorizedAccessException'.

await ProcessLauncher.RunToCompletionAsync(..."set-date.ps1", date.ToString());

set-date.ps1文件内容:

set-date.ps1 file content:

function Set-Time ([string]$dateTime) {
    $newDate = Get-Date $dateTime
    Set-Date $newDate 
}

我正在尝试寻找其他方法或尝试在模拟程序中运行ProcessLauncher,但我不知道如何在uwp上进行操作.

I'm trying to find other way to do it or try to run ProcessLauncher inside impersonator, but i don't know how to do it on uwp.

根据Microsoft:请注意,ProcessLauncher API将在当前用户凭据或DefautlAccount下启动可执行文件,因此需要管理员特权的应用程序将无法正常运行."

According Microsoft: "Note, ProcessLauncher API launches executables under the current user credentials, or DefautlAccount, so apps requiring admin priviliges will fail to run properly."

是否有帮助更改系统时钟?

Any help to change system clock?

谢谢.

推荐答案

您必须使用以下代码添加应用程序,才能将这些代码添加到Windows Iot core的 AllowedExecutableFilesList 注册表中,因此您需要使用以下命令将应用程序或文件添加到Windows注册表中的AllowedExecutableFilesList项中:

You must be Add application with below code to add those in AllowedExecutableFilesList registry in windows Iot core , so you need use below command to add applications or files to AllowedExecutableFilesList Key in windows registry:

REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\EmbeddedMode\ProcessLauncher" /v AllowedExecutableFilesList /t REG_MULTI_SZ /d "c:\windows\system32\ipconfig.exe"\0"c:\windows\system32\tlist.exe"\0"c:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe\0"

继续,使用 PowerShell .之后,您授权访问此应用程序和文件.

Go ahead, run the command above on your device, using SSH or PowerShell. after that you authorize to access this apps and files.

注意:ProcessLauncher API在当前用户凭据或DefautlAccount下启动可执行文件,因此需要管理员特权的应用将无法正常运行.

Note : ProcessLauncher API launches executables under the current user credentials, or DefautlAccount, so apps requiring admin priviliges will fail to run properly.

有关更多详细信息,请参见此链接:

see this link for more details :

https://ms-iot.github .io/content/zh-CN/win10/samples/ProcessLauncherSample.htm

这篇关于在UWP上通过ProcessLauncher更改系统时钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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