[CmdletBinding()] param( [Parameter(Mandatory = $true)] [string]$PackageRoot, [string]$SourceJobRoot = 'D:\NDC_MISSIONCORE\runtime\jobs\recorded-camera-602ac89026ed12978619801d', [string]$RuntimeRoot = 'D:\NDC_MISSIONCORE\runtime\experiments\e46f' ) $ErrorActionPreference = 'Stop' $taskName = 'MissionCore-E46FDashCamBakeoff' $package = (Resolve-Path -LiteralPath $PackageRoot).Path $script = Join-Path $package 'runtime\Invoke-E46FDashCamBakeoff.ps1' if (-not (Test-Path -LiteralPath $script -PathType Leaf)) { throw "E46F 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 "e46f-dashcam-bakeoff-$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 Mission Core E46F stock NVIDIA DashCamNet plus NvDCF detector-only bake-off.' ` -Force | Out-Null Start-ScheduledTask -TaskName $taskName Write-Host "E46F_TASK_STARTED task=$taskName log=$logPath"