fix: use Register-ScheduledTask -Force instead of delete-then-create to avoid losing tasks on failure
This commit is contained in:
@@ -563,9 +563,6 @@ function Setup-AutoStart {
|
||||
"@
|
||||
$hubScript | Set-Content $hubScriptPath -Encoding UTF8
|
||||
|
||||
$oldHub = Get-ScheduledTask -TaskName "HAPI Hub" -ErrorAction SilentlyContinue
|
||||
if ($oldHub) { Unregister-ScheduledTask -TaskName "HAPI Hub" -Confirm:$false }
|
||||
|
||||
$trigger = New-ScheduledTaskTrigger -AtLogon
|
||||
$action = New-ScheduledTaskAction -Execute "powershell.exe" `
|
||||
-Argument "-WindowStyle Hidden -ExecutionPolicy Bypass -File `"$hubScriptPath`""
|
||||
@@ -577,9 +574,6 @@ function Setup-AutoStart {
|
||||
-Principal $principal -Settings $settings -Force | Out-Null
|
||||
Write-Ok "HAPI Hub 计划任务已创建"
|
||||
|
||||
$oldRunner = Get-ScheduledTask -TaskName "HAPI Runner" -ErrorAction SilentlyContinue
|
||||
if ($oldRunner) { Unregister-ScheduledTask -TaskName "HAPI Runner" -Confirm:$false }
|
||||
|
||||
$hapiHome = Join-Path $env:USERPROFILE ".hapi"
|
||||
New-Item -ItemType Directory -Force -Path $hapiHome | Out-Null
|
||||
$settingsJson = @"
|
||||
|
||||
Reference in New Issue
Block a user