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?
Find out more ›
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."
}
Code: Select all
setup.msi AI_UPGRADE="Yes" /qn