2016-03-31 72 views
0

我正嘗試在樹莓派(uwp)上運行powershell腳本以通過c#更改系統時鐘。通過ProcessLauncher更改系統時鐘uwp

運行下面的代碼會拋出異常'System.UnauthorizedAccessException'。

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

設置date.ps1文件內容:

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

我試圖尋找其他辦法做,或嘗試運行ProcessLauncher內冒領,但我不知道該怎麼辦它在uwp上。

根據微軟:「注意,ProcessLauncher API啓動可執行文件下的當前用戶憑據,或DefautlAccount,所以應用程序需要管理員特權時將無法正常運行。」

任何幫助改變系統時鐘?

謝謝。

+0

你找到一個解決這個問題?運行https://github.com/ms-iot/samples/tree/develop/ExternalProcessLauncher/CS解決方案時出現同樣的錯誤。 –

回答

0

我不認爲這是可能的,開箱即用的安全問題。

1

你必須要添加應用程序下面的代碼添加那些AllowedExecutableFilesList在Windows註冊表物聯網的核心,所以你需要使用下面的命令來應用程序或文件在Windows註冊表中添加到AllowedExecutableFilesList重點:

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" 

繼續,使用SSHPowerShell在設備上運行上面的命令。之後,您授權訪問這些應用程序和文件。

注意ProcessLauncher API啓動可執行文件下的當前用戶憑據,或DefautlAccount,所以應用程序需要管理員特權時將無法正常運行。

看到此鏈接瞭解詳情:

https://ms-iot.github.io/content/en-US/win10/samples/ProcessLauncherSample.htm

+0

該鏈接已更改爲:https://github.com/ms-iot/samples/tree/develop/ExternalProcessLauncher/CS –