A community member has associated this post with a similar question:
MSI application not uninstalled properly after update to latest windows 10 version
Only moderators can edit this content.
MSI application uninstall not working properly after windows update
- While uninstalling the MSI Application, we have shown a custom exception message when MSI application is running in the background.
To show custom message we have override the installer file .
namespace SampleApplication
{
[RunInstaller(true)]
public partial class SampleInstaller : System.Configuration.Install.Installer
{
public override void Uninstall(IDictionary savedState)
{
if (AlreadyRunning())
{
// custom exception we throw
throw new InstallException("Sample MSI is running in background. Please close if you want to uninstall.");
}
else
{
base.Uninstall(savedState);
try
{
//other tasks
}
catch (Exception exception)
{
// error occured
}
}
private static bool AlreadyRunning()
{
Process[] processes = Process.GetProcessesByName("SampleMSI");
if (processes.Length > 0)
{
foreach (Process proc in processes)
{
var currentSessionID = Process.GetCurrentProcess().SessionId;
if (proc.SessionId == currentSessionID)
{
return true;
}
}
}
return false;
}
}
}
Issue:
In Recent windows update(Windows 10 and Windows 11), when we uninstall the MSI application when running in background, the above custom exception is displayed and parallelly the application is removed from the Control Panel's "Programs and Features", but other associated files are not removed.
Then we have closed the background running application and try to install or uninstall again, the below error message is displayed and we can't completely uninstall or remove the installed MSI.
"This advertised application is unsafe and will not be installed. Contact your administrator to change the package installation user interface option to Basic."
Unlike previous windows versions, where the uninstallation process would stop when encountering the custom exception message.
Is there any problem with the above override installer code?
Kindly help us to solve this issue.