# URL to the application's installer $downloadUrl = "https://pinotage.centrastage.net/csm/profile/downloadAgent/key-site" # Path where the installer will be saved $downloadPath = "C:\Windows\Temp\agentsetup.exe" # Path to the uninstaller of the current application $uninstallPath = "C:\Program Files (x86)\CentraStage\uninst.exe" # Optional arguments for the uninstallation $uninstallArgs = "/uninstall /quiet" # Optional arguments for the installation $installArgs = "/silent" # Download the installer Write-Output "Downloading the installer..." Invoke-WebRequest -Uri $downloadUrl -OutFile $downloadPath Write-Output "The installer has been downloaded to $downloadPath." # Start the uninstallation $uninstallProcess = Start-Process -FilePath $uninstallPath -ArgumentList $uninstallArgs -PassThru # Wait until the uninstallation is completed Write-Output "Waiting for the uninstallation to complete..." Wait-Process -Id $uninstallProcess.Id Write-Output "The uninstallation is complete." # Start the installation $installProcess = Start-Process -FilePath $downloadPath -ArgumentList $installArgs -PassThru # Wait until the installation is completed Write-Output "Waiting for the installation to complete..." Wait-Process -Id $installProcess.Id Write-Output "The installation is complete." # Remove the downloaded installer Write-Output "Removing the downloaded installer..." Remove-Item -Path $downloadPath -Force Write-Output "The downloaded installer has been removed." Write-Output "De installatie is voltooid."