donj
Posts: 7
Joined: Tue May 11, 2021 2:09 pm

How to remove old version of software being installed in PowerShell Script

Mon May 24, 2021 4:26 pm

I want to remove old version of software being installed in PowerShell script.
How to do this?
Can I get the sample script?

Catalin
Posts: 4364
Joined: Wed Jun 13, 2018 7:49 am

Re: How to remove old version of software being installed in PowerShell Script

Tue May 25, 2021 5:03 pm

Hello,

I am not quite sure I understand your scenario here.

Could you please give me some more details about what you want to achieve so I can further assist?

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

donj
Posts: 7
Joined: Tue May 11, 2021 2:09 pm

Re: How to remove old version of software being installed in PowerShell Script

Tue May 25, 2021 6:58 pm

If you go to the following link, there is upgrades page.
https://www.advancedinstaller.com/user- ... rades.html

I want to do this from the PowerShell Script.
I've looked into the PowerShell Automation document but couldn't figure out how to do in PowerShell script.
Attachments
Capture.PNG
Capture.PNG (71.97 KiB) Viewed 6614 times

donj
Posts: 7
Joined: Tue May 11, 2021 2:09 pm

Re: How to remove old version of software being installed in PowerShell Script

Thu May 27, 2021 4:56 pm

When try installing our package, if old version already exists in the application folder, an error occur. In this case, we uninstall it from Windows and install new package. I want to delete existing package before we install new package. I want to do this from PowerShell script.

Catalin
Posts: 4364
Joined: Wed Jun 13, 2018 7:49 am

Re: How to remove old version of software being installed in PowerShell Script

Thu May 27, 2021 5:17 pm

Hello,
When try installing our package, if old version already exists in the application folder, an error occur. In this case, we uninstall it from Windows and install new package. I want to delete existing package before we install new package. I want to do this from PowerShell script.
Could you please tell me what the encountered error is here?

Also, is there a specific reason you want to do this through PowerShell?

I am asking this because the default behavior of Windows Installer does exactly what you need.

If you want to remove an older setup, all you have to do is:

- go to "Product Details" page and increase the version (e.g. version 1.0.0 becomes 1.0.1)

When doing the above, you will be asked to change the ProductCode.

- change the ProductCode
I've looked into the PowerShell Automation document but couldn't figure out how to do in PowerShell script.
Please note that the "PowerShell Automation" feature is intended to help automate the creation of your project through PowerShell (e.g. creating a new Advanced Installer project, adding files to it, setting icons, etc.).

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

donj
Posts: 7
Joined: Tue May 11, 2021 2:09 pm

Re: How to remove old version of software being installed in PowerShell Script

Thu May 27, 2021 6:40 pm

I attached the error message.

The Advanced Installed is used from CI of Bamboo.
I want to have advanced installer remove old installation from PowerShell script.
Attachments
Capture.PNG
Capture.PNG (8.08 KiB) Viewed 6586 times

Catalin
Posts: 4364
Joined: Wed Jun 13, 2018 7:49 am

Re: How to remove old version of software being installed in PowerShell Script

Fri May 28, 2021 9:36 am

Hello,

Thank you for your followup on this!

This is the error I expected you were getting.

This is happening because the products have the same ProductCode.

This is highlighted in our "Product Identification (ProductCode and UpgradeCode)" article:
Also, it is important to note that two products with the same ProductCode can not be installed on the same computer. Windows Installer will prevent this with an error reading:

Another version of this product is already installed. Installation of this version cannot continue. To configure or remove the existing version of this product, use Programs and Features in the Control Panel.
With that being said, to avoid this, we need to do two things:

- increase the product's version (e.g. from 1.0.0 to 1.0.1)

- change the ProductCode

Let's consider you have already created a project. To achieve the above in PowerShell, you can proceed as it follows:
NewProdCode.png
NewProdCode.png (99.11 KiB) Viewed 6573 times

Hope this helps!

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

donj
Posts: 7
Joined: Tue May 11, 2021 2:09 pm

Re: How to remove old version of software being installed in PowerShell Script

Wed Jun 02, 2021 3:20 pm

Thanks for the information.
I'm going to try this.
BTW, is the GenerateProductCode() provided? I can't find it from the Advanced Installer document.

Catalin
Posts: 4364
Joined: Wed Jun 13, 2018 7:49 am

Re: How to remove old version of software being installed in PowerShell Script

Wed Jun 02, 2021 4:42 pm

Hello,

You are always welcome!
BTW, is the GenerateProductCode() provided? I can't find it from the Advanced Installer document.
I am not quite sure I understand your question here. Could you please give me some more details?

The "GenerateProductCode()" method is the same as going to "Product Details" page --> "ProductIDs" tab --> "Generate All" button.

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

Return to “Building Installers”