pforsbom
Posts: 23
Joined: Mon Apr 01, 2019 11:03 am

Update Advanced Installer with script

Tue Mar 05, 2024 10:17 am

Hi
In my build pipeline I would like to make sure Advanced Installer software is at the latest version.
How can I script an update of Advanced Installer?

pforsbom
Posts: 23
Joined: Mon Apr 01, 2019 11:03 am

Re: Update Advanced Installer with script

Tue Mar 05, 2024 1:16 pm

Hi
Me ,ChatGPT and Fiddler figured this oue out our selves :D

Code: Select all

# PowerShell script to update Advanced Installer to the latest version

# Define the URL where updates.ini for Advanced Installer is located
$updatesIniUrl = "https://www.advancedinstaller.com/downloads/updates.ini"

# Attempt to download updates.ini content
$response = Invoke-WebRequest -Uri $updatesIniUrl -UseBasicParsing

# Attempt to convert the content assuming it's ASCII or UTF8 encoded text
$updatesIni = [System.Text.Encoding]::UTF8.GetString($response.Content)

# Initialize variables for latest version and download URL
$latestVersion = $null
$downloadUrl = $null

# Extract the latest version information (assuming the first entry is the latest)
if ($updatesIni -match 'ProductVersion\s*=\s*([^\r\n]+)') {
    $latestVersion = $matches[1].Trim()
}

if ($updatesIni -match 'URL\s*=\s*([^\r\n]+)') {
    $downloadUrl = $matches[1].Trim()
}

# Check if we successfully retrieved version and URL
if ($null -eq $latestVersion -or $null -eq $downloadUrl) {
    Write-Output "Failed to retrieve the latest Advanced Installer version information."
    exit
}

# Define the registry path where Advanced Installer's version is stored
$registryPath = "HKLM:\SOFTWARE\WOW6432Node\Caphyon\Advanced Installer"
$currentVersion = (Get-ItemProperty -Path $registryPath -ErrorAction SilentlyContinue).Version

# Output the current and latest versions
Write-Output "Current version of Advanced Installer: $currentVersion"
Write-Output "Latest available version of Advanced Installer: $latestVersion"

# Compare the current version with the latest version
if ($currentVersion -eq $latestVersion) {
    Write-Output "Advanced Installer is already up to date."
} elseif ($null -eq $currentVersion) {
    Write-Output "Advanced Installer is not installed."
} else {
    Write-Output "A newer version of Advanced Installer is available."

    # Define the path where the installer will be downloaded
    $directoryPath = "C:\Temp\Advanced Installer v. $latestVersion"
    New-Item -ItemType Directory -Force -Path $directoryPath

    # Define the path where the installer will be downloaded
    $downloadPath = "$directoryPath\advinst_latest.msi"

    # Download the latest version of Advanced Installer
    Invoke-WebRequest -Uri $downloadUrl -OutFile $downloadPath -UseBasicParsing

    # Install the new version silently without forcing the system to restart
    Start-Process "msiexec.exe" -ArgumentList "/i `"$downloadPath`" /qn /norestart" -Wait -NoNewWindow

    # Optionally, remove the downloaded installer to free up space
    Remove-Item -Path $downloadPath

    # Display a confirmation message
    Write-Output "Advanced Installer has been updated to the latest version."
}


pforsbom
Posts: 23
Joined: Mon Apr 01, 2019 11:03 am

Re: Update Advanced Installer with script

Tue Mar 05, 2024 1:43 pm

My only question now is how do execute msiexec on the msi and select "Remove Older Versions" option?

Liviu
Posts: 1026
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: Update Advanced Installer with script

Wed Mar 06, 2024 8:51 am

Hello,

You can set the AI_UPGRADE property from the command line.

Code: Select all

setup.msi AI_UPGRADE="Yes" /qn
where the AI_UPGRADE property has the value "Yes" if you want to remove the older versions, or value "No" if you want to install side by side.

Hope this helps!

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

pforsbom
Posts: 23
Joined: Mon Apr 01, 2019 11:03 am

Re: Update Advanced Installer with script

Wed Mar 06, 2024 1:38 pm

Excellent!
Thank you

Liviu
Posts: 1026
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: Update Advanced Installer with script

Wed Mar 06, 2024 1:58 pm

You're always welcome!

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”