【发布时间】:2016-07-20 05:41:02
【问题描述】:
我正在尝试在 raspberry (uwp) 上运行 powershell 脚本以通过 c# 更改系统时钟。
运行下面的代码会抛出异常“System.UnauthorizedAccessException”。
await ProcessLauncher.RunToCompletionAsync(..."set-date.ps1", date.ToString());
set-date.ps1 文件内容:
function Set-Time ([string]$dateTime) {
$newDate = Get-Date $dateTime
Set-Date $newDate
}
我正在尝试寻找其他方法来执行此操作或尝试在模拟程序中运行 ProcessLauncher,但我不知道如何在 uwp 上执行此操作。
据微软称:“注意,ProcessLauncher API 在当前用户凭据或 DefautlAccount 下启动可执行文件,因此需要管理员权限的应用程序将无法正常运行。”
对更改系统时钟有帮助吗?
谢谢。
【问题讨论】:
-
您找到解决此问题的方法了吗?运行github.com/ms-iot/samples/tree/develop/ExternalProcessLauncher/… 解决方案时出现同样的错误。
标签: c# powershell raspberry-pi win-universal-app impersonation