kevintran1308
Posts: 11
Joined: Tue May 14, 2024 5:56 am

Could not uninstall package with Powershell

Hi,

I have software install in parallel so it could not uninstall automatic.
So I tried to uninstall package using powershell.
Below is the script that I wrote.
Image

However, the script fail to run.
Image

I tried the WMI Method to install the package too but no hope.
I don't know where the error is.

Ps: I have some custom actions run with powershell run before this custom action run.
Image

Thank you
Kevin
Liviu
Posts: 1325
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: Could not uninstall package with Powershell

Hello Kevin,

This might happen due to an old Windows limitation that prevents two installation packages from running on a machine at the same time.

Are you trying to remove an old version of your setup? If so, you can check the following articles:

1. Migration to a New Installer Tool: Upgrading Older Versions of the Installer
2. How to upgrade an older version of the package created with another tool and it is not MSI-based

You can also try a PowerShell script to launch the uninstaller with the -Wait argument and scheduled like this::

Script content:

Code: Select all

#Requires -version 3
Param()

$pathToUninstall = "C:\Program Files\PostgreSQL\16\uninstall-postgresql.exe"

start-process -filepath $pathToUninstall -Wait 

or

Code: Select all

Start-process "msiexec.exe" -ArgumentList "/x {F112129C-CBDC-4103-BDDE-4FCD6906A520)" -Wait
start process.png
start process.png (141.33 KiB) Viewed 14568 times

Please note that the above custom action can only run on UI sequence. Windows Installer (MSI) has a limitation by design that prevents multiple MSI installations or uninstallations from running simultaneously. This means that you cannot initiate the installation or uninstallation of one MSI package while another is still in progress.

In your specific scenario, you are trying to uninstall an MSI package while another MSI installation is ongoing. This isn't supported by the Windows Installer due to its design, which locks the installer service to ensure data integrity and avoid conflicts that could lead to system corruption or incomplete installations.

If you can't get this to work, can you please send us by email to support at advancedinstaller dot com the following resources:

1. the .AIP project file.
2. a download link for your setup package built with Advanced Installer.
3. a download for the package you are trying to uninstall.

so we can further test this.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
kevintran1308
Posts: 11
Joined: Tue May 14, 2024 5:56 am

Re: Could not uninstall package with Powershell

Here’s a brief overview of the AIP project I created:
Test.aip
(43.84 KiB) Downloaded 473 times
Our program supports parallel installations with the following structure:

Product Version: 1.0.0.1, installed at C:\Product-1.0.0.1
Product Version: 2.0.0.2, installed at C:\Product-2.0.0.2
Product Version: 3.0.0.3, installed at C:\Product-3.0.0.3
We have a maximum limit of 3 products installed concurrently. If the user attempts to install a fourth version, they must choose which of the existing versions to replace with the new one.

For example, if version 4.0.0.4 is being installed, it will replace version 2.0.0.2. The installer will first copy data from version 2.0.0.2 to the new installation path at C:\Product-4.0.0.4. After copying, the new version will be installed, overwriting the old data.

Once version 4.0.0.4 is successfully installed, I intend to use PowerShell to uninstall version 2.0.0.2. However, I encountered an error (details below).

I haven't followed the suggestions provided, but I still can't uninstall the package.
Could you please provide some advice?

Regards,
Kevin
Liviu
Posts: 1325
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: Could not uninstall package with Powershell

Hello Kevin,

I've replied to your email.

Let's continue the conversation there until we reach a conclusion.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
kevintran1308
Posts: 11
Joined: Tue May 14, 2024 5:56 am

Re: Could not uninstall package with Powershell

Hi Liviu,

I found an article on a website that explains how users can choose between installing a new version of software side-by-side with the old version or removing the old version to install the new one using UpgradeDlg.

https://www.advancedinstaller.com/user- ... dedlg.html

The article mentions an option to remove all old versions. Is there a way to selectively remove only specific old versions instead?

Kevin
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Could not uninstall package with Powershell

Hi Kevin,

You can try to control the specific versions you want to selectively remove from "Upgrades" page.

Just go to "Upgrades" page and check the "Customize Advanced Installer upgrade rules" option. Then double click on the OLDPRODUCTS row under "Upgrades" section and configure the "Versions To Upgrade" fields.
screen1.png
screen1.png (217.15 KiB) Viewed 10159 times
Here you can define a range of Product Versions you want to be upgraded in case "Yes, remove old versions" option is selected on "UpgradesDlg" dialog.

However, this range of versions can be defined and set only when building your setup project, at build time. If you want to be able control this range of versions at install time (when your setup is run) I am afraid this is not possible.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Catalin
Posts: 7513
Joined: Wed Jun 13, 2018 7:49 am

Re: Could not uninstall package with Powershell

Hello James,
Thanks for answering, you made my day. If I want to know more, I will ask by starting my own thread.
You are always welcome!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”