54 lines
2.2 KiB
PowerShell
54 lines
2.2 KiB
PowerShell
[CmdletBinding()]
|
|
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$PackageRoot,
|
|
|
|
[string]$SourceJobRoot = 'D:\NDC_MISSIONCORE\runtime\jobs\recorded-camera-602ac89026ed12978619801d',
|
|
|
|
[string]$RuntimeRoot = 'D:\NDC_MISSIONCORE\runtime\experiments\e46h'
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
$taskName = 'MissionCore-E46HFullRectifiedFrontReplay'
|
|
$package = (Resolve-Path -LiteralPath $PackageRoot).Path
|
|
$script = Join-Path $package 'runtime\Invoke-E46HFullRectifiedFrontReplay.ps1'
|
|
if (-not (Test-Path -LiteralPath $script -PathType Leaf)) {
|
|
throw "E46H runner is missing: $script"
|
|
}
|
|
$existing = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
|
|
if ($existing -and $existing.State -eq 'Running') {
|
|
throw "$taskName is already running."
|
|
}
|
|
$logsRoot = Join-Path $RuntimeRoot 'logs'
|
|
New-Item -ItemType Directory -Force -Path $logsRoot | Out-Null
|
|
$stamp = (Get-Date).ToUniversalTime().ToString('yyyyMMddTHHmmssfffZ')
|
|
$logPath = Join-Path $logsRoot "e46h-full-rectified-front-$stamp.log"
|
|
$powerShell = "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe"
|
|
$arguments = @(
|
|
'-NoLogo', '-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass',
|
|
'-File', "`"$script`"",
|
|
'-PackageRoot', "`"$package`"",
|
|
'-SourceJobRoot', "`"$SourceJobRoot`"",
|
|
'-RuntimeRoot', "`"$RuntimeRoot`"",
|
|
'-LogPath', "`"$logPath`""
|
|
) -join ' '
|
|
$userId = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
|
|
$action = New-ScheduledTaskAction -Execute $powerShell -Argument $arguments -WorkingDirectory $package
|
|
$principal = New-ScheduledTaskPrincipal -UserId $userId -LogonType Interactive -RunLevel Limited
|
|
$trigger = New-ScheduledTaskTrigger -Once -At ((Get-Date).AddMinutes(30))
|
|
$settings = New-ScheduledTaskSettingsSet `
|
|
-AllowStartIfOnBatteries `
|
|
-DontStopIfGoingOnBatteries `
|
|
-StartWhenAvailable `
|
|
-ExecutionTimeLimit ([TimeSpan]::FromHours(6))
|
|
Register-ScheduledTask `
|
|
-TaskName $taskName `
|
|
-Action $action `
|
|
-Principal $principal `
|
|
-Trigger $trigger `
|
|
-Settings $settings `
|
|
-Description 'One-shot E46H full retained FRONT TrafficCamNet + NvDCF replay.' `
|
|
-Force | Out-Null
|
|
Start-ScheduledTask -TaskName $taskName
|
|
Write-Host "E46H_TASK_STARTED task=$taskName log=$logPath"
|