[CmdletBinding()] param( [Parameter(Mandatory = $true)] [string]$BuildScript, [Parameter(Mandatory = $true)] [string]$SourceRoot, [Parameter(Mandatory = $true)] [string]$OutputRoot ) $ErrorActionPreference = 'Stop' $taskName = 'MissionCore-E46ENvidiaTaoParser' $script = (Resolve-Path -LiteralPath $BuildScript).Path $source = (Resolve-Path -LiteralPath $SourceRoot).Path New-Item -ItemType Directory -Force -Path $OutputRoot | Out-Null $output = (Resolve-Path -LiteralPath $OutputRoot).Path $existing = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue if ($existing -and $existing.State -eq 'Running') { throw "$taskName is already running." } $logsRoot = 'D:\NDC_MISSIONCORE\runtime\experiments\e46e\logs' New-Item -ItemType Directory -Force -Path $logsRoot | Out-Null $stamp = (Get-Date).ToUniversalTime().ToString('yyyyMMddTHHmmssfffZ') $logPath = Join-Path $logsRoot "e46e-parser-build-$stamp.log" $powerShell = "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" $arguments = @( '-NoLogo', '-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-File', "`"$script`"", '-SourceRoot', "`"$source`"", '-OutputRoot', "`"$output`"", '-LogPath', "`"$logPath`"" ) -join ' ' $userId = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name $action = New-ScheduledTaskAction -Execute $powerShell -Argument $arguments -WorkingDirectory $source $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(3)) Register-ScheduledTask -TaskName $taskName -Action $action -Principal $principal ` -Trigger $trigger -Settings $settings ` -Description 'Build the pinned official NVIDIA DeepStream TAO RT-DETR parser.' -Force | Out-Null Start-ScheduledTask -TaskName $taskName Write-Host "E46E_PARSER_TASK_STARTED task=$taskName log=$logPath"