mustRun(); return $process->getOutput(); }; $scheduler = getenv('SystemRoot').'/System32/schtasks.exe'; $before = $run([$scheduler, '/Query', '/TN', $plan['task_name'], '/XML']); $installation = json_decode(file_get_contents($root.'/docs/proofs/approval-deadlines-task-installation.json'), true, 32, JSON_THROW_ON_ERROR); $original = file_get_contents($installation['private_definition']); if (! hash_equals($installation['private_installed_xml_sha256'], hash('sha256', $original)) || DeadlineTaskGuiAction::canonical($original) !== DeadlineTaskGuiAction::canonical($before)) { throw new LogicException('Installed task differs from its original verified definition.'); } DeadlineTaskGuiAction::replacement($before, $old, $new); if ($argv[1] === '--preview') { echo json_encode(['state' => 'preview', 'same_task_script_and_policy' => true, 'task_changed' => false], JSON_THROW_ON_ERROR).PHP_EOL; exit; } $directory = 'C:/laragon/data/compras/tasks/deadline-gui-'.gmdate('Ymd-His').'-'.bin2hex(random_bytes(6)); if (! mkdir($directory, 0700, true) || file_put_contents($directory.'/before.private.xml', WindowsTaskXml::encode($before)) === false) { throw new LogicException('Private original task backup required.'); } // Native cmdlet changes the action only; no script file or execution-policy override. $command = <<<'POWERSHELL' $ErrorActionPreference='Stop' $task=Get-ScheduledTask -TaskName 'Compras-Pilot-Approval-Deadlines' -TaskPath '\' if($task.Actions.Count -ne 1 -or $task.Actions[0].Execute -ne 'C:/Users/macbook/.config/investmoz/php-8.5.11/php.exe'){throw 'Task action changed'} $action=New-ScheduledTaskAction -Execute 'C:/Users/macbook/.config/investmoz/php-8.5.11/php-win.exe' -Argument $task.Actions[0].Arguments -WorkingDirectory $task.Actions[0].WorkingDirectory Set-ScheduledTask -TaskName 'Compras-Pilot-Approval-Deadlines' -TaskPath '\' -Action $action | Out-Null POWERSHELL; $run([getenv('SystemRoot').'/System32/WindowsPowerShell/v1.0/powershell.exe', '-NoProfile', '-NonInteractive', '-Command', $command]); $after = $run([$scheduler, '/Query', '/TN', $plan['task_name'], '/XML']); DeadlineTaskGuiAction::assertConserved($before, $after, $old, $new); file_put_contents($directory.'/after.private.xml', WindowsTaskXml::encode($after)); $run([$scheduler, '/Run', '/TN', $plan['task_name']]); $result = ['date' => gmdate('c'), 'state' => 'definition_verified_awaiting_passage', 'task_name' => $plan['task_name'], 'authority' => ['approval-deadlines-task-authorization.json', 'inventory-conversion-pilot-authorization.json'], 'private_backup' => $directory, 'old_executable' => $old, 'new_executable' => $new, 'gui_binary_sha256' => hash_file('sha256', $new), 'only_executable_changed' => true, 'helper_sha256' => hash_file('sha256', $root.'/'.$plan['action_script']), 'arguments_working_directory_triggers_principal_privileges_overlap_and_limit_preserved' => true, 'powershell_execution_policy_changed' => false, 'business_policy_or_grants_changed' => false, 'reference' => 'https://www.php.net/manual/en/features.commandline.php']; file_put_contents($resultPath, json_encode($result, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR).PHP_EOL); echo json_encode($result, JSON_THROW_ON_ERROR).PHP_EOL;