I have a question regarding the behaviour of the auto update scheduled task.
i've noticed that when the executable runs and downloads the update files, after completing the installation the updater still runs in the background.
The scheduled task is created with Advanced Installer, however to get the updates to run completely silently in the background we update the scheduled task (well, technically i delete it if it exists and recreate it using a custom action).
Code: Select all
# Block for declaring the script parameters.
#Param()
# Your code goes here.
# Your code goes here.
if ($(Get-ScheduledTask -TaskName "Updater" -ErrorAction SilentlyContinue).TaskName -eq "Updater"){
Unregister-ScheduledTask -TaskName "Updater" -Confirm:$false
}
$action = ( New-ScheduledTaskAction -Execute 'C:\Windows\System32\WindowsPowershell\v1.0\powershell.exe' -Argument "-WindowStyle Hidden -NonInteractive -NoLogo -NoProfile -ExecutionPolicy Bypass C:\ProgramData\path\Config\ConfigUpdateMSI.ps1"),
(New-ScheduledTaskAction -Execute "C:\Program Files\path\Updater.exe")
$taskName = "Updater"
$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Minutes 10) -RandomDelay 00:20:00
<#trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Minutes 180) -RepetitionDuration "PT10M" (New-TimeSpan -Minutes (10 * 1)) -RandomDelay 00:20:00#>
$principal = New-ScheduledTaskPrincipal -UserId "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount -RunLevel Highest
$settings = New-ScheduledTaskSettingsSet -MultipleInstances Parallel
$description = "Scheduled task to check for updates to the Application"
Register-ScheduledTask -TaskName $taskName -Action $action -Trigger $trigger -Description $description -Settings $settings -Principal $principal1) initially, this was set with a repetition duration of 7200 hours.
2) I removed the repetition duration, now it is set to indefinitely.
If i trigger the task, it runs and does its thing but the update exe continues to run, I'm thinking this might be due to the task running indefinitely but I'm not sure. Is this the expected behaviour?
If so, how could we stop the process after it has completed. If this isn't the expected behaviour then could someone point me in the right direction as to what might be happening?
Thanks!
PhilB
FOLLOW US
Get the latest news in Application Packaging