Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell Windows IoT计划任务未运行_Powershell_Raspberry Pi_Scheduled Tasks_Windowsiot_Windows Task Scheduler - Fatal编程技术网

Powershell Windows IoT计划任务未运行

Powershell Windows IoT计划任务未运行,powershell,raspberry-pi,scheduled-tasks,windowsiot,windows-task-scheduler,Powershell,Raspberry Pi,Scheduled Tasks,Windowsiot,Windows Task Scheduler,我正在尝试为Raspberry Pi上的Windows IoT创建一个计划任务,以便在启动时运行,以检查实时时钟上的时间,然后相应地设置系统时间。有关上下文,请参阅: 我有一个PS脚本,它运行以下命令: $CurrentDate = ( c:\shares\boot\SetTimeTool.exe ) |Out-String set-date $CurrentDate 如果我运行c:\shares\boot\UpdateTime.ps1时间会根据需要更新 然后,我创建了一个计划任务: sch

我正在尝试为Raspberry Pi上的Windows IoT创建一个计划任务,以便在启动时运行,以检查实时时钟上的时间,然后相应地设置系统时间。有关上下文,请参阅:

我有一个PS脚本,它运行以下命令:

$CurrentDate = ( c:\shares\boot\SetTimeTool.exe )  |Out-String
set-date $CurrentDate
如果我运行
c:\shares\boot\UpdateTime.ps1
时间会根据需要更新

然后,我创建了一个计划任务:

schtasks /create /tn "Update Time Script" /tr C:\shares\boot\UpdateTime.ps1 /sc onstart /ru SYSTEM
如果我将时间设置为不正确的值并重新启动,则启动后时间不会更改。此外,如果我尝试按需运行计划任务:

schtasks /run /tn "Update Time Script"
我得到以下响应,但时间未更新:

SUCCESS: Attempted to run the scheduled task "Update Time Script".

感谢您的帮助

已解决:需要从依次调用powershell脚本文件的计划任务调用.bat文件。schtasks.exe无法直接调用powershell脚本。