I am using wix installer to install an msi file (Please see the code at the bottom). Doing so, its able to install fine. I can se the folder under,
C:Program FilesPharmSpec
But not I want to uninstall this file when they rerun the installer or upgrade to a newer version of the installer. I have the following piece of code that’s doing that. I can see the PharmSpec folder deleted from C:Program Files and I can see the desktop shortcut icon being deleted. But problem is, I can’t get it to go from the Control Panel. Please help.
public static class UninstallPrevVersion
{
private const string UNINSTALL_COMMAND = "/quiet /x {0} ALLUSERS=1 ARPSYSTEMCOMPONENT=1 MSIFASTINSTALL=7 SERIALNUMBER=X DBSELECTED=1 PHARMSPECSELECTED=1 REBOOT=ReallySuppress IGNOREDEPENDENCIES=ALL REMOVE=ALL;";
public static void UninstallOldPharm( WixBootstrapper bootstrapper, string msiProductCode)
{
bootstrapper.Engine.Log(LogLevel.Verbose, "starting uninstall old Pharmspec version for upgrade");
string command = string.Format(UNINSTALL_COMMAND, msiProductCode, bootstrapper.Engine.StringVariables["PreviousSerial"]);
bootstrapper.Engine.Log(LogLevel.Verbose, command);
ProcessStartInfo info = new ProcessStartInfo("msiexec", command);
info.UseShellExecute = false;
info.CreateNoWindow = false;
info.WindowStyle = ProcessWindowStyle.Hidden;
Process proc = new Process();
proc.StartInfo = info;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
string outputD = proc.StandardOutput.ReadToEnd();
if (proc.WaitForExit(60000))
{
bootstrapper.Engine.Log(LogLevel.Verbose, outputD);
}
else
{
bootstrapper.Engine.Log(LogLevel.Verbose, "Process timeout in UninstallOldPharm");
}
bootstrapper.Engine.Log(LogLevel.Verbose, "uninstalled old PharmSpec version for upgrade");
}
}
DEBUGGING:
On the command prompt, I am running the above UNINSTALL_COMMAND as follows,
msiexec /quiet /x {959C7390-F8FE-4E7C-BF34-27357313F135} ALLUSERS=1 ARPSYSTEMCOMPONENT=1 MSIFASTINSTALL=7 SERIALNUMBER=X DBSELECTED=1 PHARMSPECSELECTED=1 REBOOT=ReallySuppress IGNOREDEPENDENCIES=ALL REMOVE=ALL;
I am getting the number {959C7390-F8FE-4E7C-BF34-27357313F135} from regedit
HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall{959C7390-F8FE-4E7C-BF34-27357313F135}
When I run this command, I can see the PharmSpec folder deleted from C:Program Files and the desktop icon being removed too. But under Control Panel and the registry in the above path, I still see them. How can I remove the PharmSpec from the ControlPanel. When I reinstall a newer version of the installer, I can see 2 entries in the Control Panel with 2 different versions.
Here is how the PharmSpec.msi package is being installed,
<PackageGroup Id="PharmSpecMsi">
<MsiPackage Id="PharmSpecInstaller"
SourceFile="$(var.ReleaseFolder)!(loc.CULTURE)PharmSpec.msi"
DisplayInternalUI="yes"
ForcePerMachine="yes"
Visible="no"
InstallCondition="1">
<MsiProperty Name="UPGRADEPHARM" Value="[MAINUPGRADE]"/>
<MsiProperty Name="ADD_USER_ADMIN" Value="[UserAdmin]"/>
<MsiProperty Name="ADD_USER_CALTECH" Value="[TechUser]"/>
<MsiProperty Name="CUSTOMER" Value="[Customer]"/>
<MsiProperty Name="SERIALNUMBER" Value="[CdKey]"/>
<MsiProperty Name="REGSEVERITY" Value="[Severity]"/>
<MsiProperty Name="DBSERVERNAME" Value="[DBServerName]"/>
<MsiProperty Name="DBDSN" Value="[Dbdsn]"/>
<MsiProperty Name="DBUID" Value="[Dbuid]"/>
<MsiProperty Name="DBPWD" Value="[Dbpwd]"/>
<MsiProperty Name="REGDATE" Value="[RegDate]"/>
<MsiProperty Name="REGLANG" Value="[RegLang]"/>
<MsiProperty Name="REGSEP" Value="[RegSep]"/>
<MsiProperty Name="REGTIME" Value="[RegTime]"/>
<MsiProperty Name="DBSELECTED" Value="[INSTALLSQL]"/>
<MsiProperty Name="NOTCURRENTDB" Value="[Sql2022InstanceFound]"/>
<MsiProperty Name="PHARMSPECSELECTED" Value="[INSTALLPHARM]"/>
<MsiProperty Name="OLDDBDATAPATH" Value="[OLDDBDATAPATH]"/>
<MsiProperty Name="INSTALLDIR" Value="[InstallDir]"/>
<MsiProperty Name="TARGETDIR" Value="[TargetDir]"/>
</MsiPackage>
</PackageGroup>