Change system clock by ProcessLauncher on uwp

2019-08-13 18:52发布

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.

2条回答
Summer. ? 凉城
2楼-- · 2019-08-13 19:28

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

查看更多
走好不送
3楼-- · 2019-08-13 19:32

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

查看更多
登录 后发表回答