Change system clock by ProcessLauncher on uwp

别说谁变了你拦得住时间么 提交于 2019-12-13 19:41:15

问题


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

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

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

set-date.ps1 file content:

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

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.

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?

Thank you.


回答1:


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"

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

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/en-US/win10/samples/ProcessLauncherSample.htm




回答2:


I don't think this is possible, out of the box, for security questions.



来源:https://stackoverflow.com/questions/36338991/change-system-clock-by-processlauncher-on-uwp

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