We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

philb1208
Posts: 44
Joined: Thu Jul 04, 2019 3:24 pm

Automatic updater.exe continues to run after updating.

Hi,

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 $principal

1) 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
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Automatic updater.exe continues to run after updating.

Hello Phil,

By having a look over your PowerShell script, I would say this is happening due to the "-RepetitionInterval" parameter. If I understand that correctly, the scheduled task will try to run the updater every 10 minutes.
-RepetitonInterval

Specifies an amount of time between each restart of the task. The task will run, wait for the time interval specified, and then run again.
With that being said, I would say that this is the normal behavior.

Normally, I would assume the task to only be ran once, since the "-Once" parameter is passed, however this does not seem to be the case here. Perhaps the "-Once" and the "-RepetitionInterval" parameters cancel eachother.

Could you please try to remove the "-RepetitionInterval" from your script, rebuild the project and retest the scenario? Is this still happening when doing so?

Hope this helps somehow.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
philb1208
Posts: 44
Joined: Thu Jul 04, 2019 3:24 pm

Re: Automatic updater.exe continues to run after updating.

Hi Catalin,

Thanks for responding. Sorry for the delay. I found a way in the end using powershell. A service we install allows us to pass in custom scripts, so when this service is running the script will check if the updater is still running and kill the process.

You confirmed what i suspected, but I will try your suggestion next. I don't really like relying on a powershell script to do this for me so if i can update the task to work how i want then perfect.

Thanks

Phil
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Automatic updater.exe continues to run after updating.

You are always welcome, Phil!

No worries about the delay.
I found a way in the end using powershell.
I am glad you were able to figure things out.
You confirmed what i suspected, but I will try your suggestion next. I don't really like relying on a powershell script to do this for me so if i can update the task to work how i want then perfect.
Sure thing. I hope the solution will work as expected.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”