We've been doing way too many builds recently and the old routine of uninstalling the old build before running the build was getting tired so I did a bit of digging and found out how to remove an msi using PowerShell:
This is the part of the script that uninstalls the old build:
This is the part of the script that uninstalls the old build:
$data = gp HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select 
DisplayName, DisplayVersion | where {$_ -match "MyApplication"}
if ($data)
{
 $version = $data.DisplayVersion
 echo "MyApplication  is already installed. Current Version is $version"
 echo "Uninstalling version $version"
 $app = Get-WmiObject -Class Win32_product | Where-Object { $_.Name -match "MyApplication"}
 $app.Uninstall() > $null
}
$exitcode = $app.Uninstall() echo "exit code: $($var.ReturnValue)"
 
No comments:
Post a Comment