Force Scheduled Task Unregistration

This commit is contained in:
Manuel Thalmann 2023-06-28 21:20:59 +02:00
parent 6a4ff4645a
commit c3d8e79fcf

View file

@ -49,7 +49,8 @@ function Enable-UACNextLogin() {
$action = New-ScheduledTaskAction -Execute "pwsh.exe" -Argument ("-c " + ` $action = New-ScheduledTaskAction -Execute "pwsh.exe" -Argument ("-c " + `
"Set-ItemProperty `"$keyPath`" -Name `"$propertyName`" -Value 0;" + ` "Set-ItemProperty `"$keyPath`" -Name `"$propertyName`" -Value 0;" + `
"Unregister-ScheduledTask $taskName;"); "Unregister-ScheduledTask -Force $taskName;");
$trigger = New-ScheduledTaskTrigger -AtLogOn; $trigger = New-ScheduledTaskTrigger -AtLogOn;
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest; $principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest;
$task = New-ScheduledTask -Action $action -Principal $principal -Trigger $trigger; $task = New-ScheduledTask -Action $action -Principal $principal -Trigger $trigger;