My problem - Advanced Installer Community
EdwardSanchez
Posts: 2
Joined: Wed Jun 03, 2020 5:20 am

My problem

Hello,

My current problem is that I wish to display the currently installed version of my product before installing a newer version. Currently, my product will silently uninstall the current version and then display the new installation when running my exe. I would like to display a prompt before this step so that the user can see what version they have currently installed, and have the option to accept or refuse the new installation. Is there a way I can accomplish this?

Thanks for help.
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: My problem

Hello Edward and welcome to Advanced Installer forums,

In order to achieve this, we will have to retrieve the version number from the previously installed version of our product.

In order to do so, we will need a custom action.

Here, you can use any language that you are familiar with. For instance, I have used PowerShell and here is how the script looks like:

Code: Select all

# Block for declaring the script parameters.
Param()

Add-Type -AssemblyName PresentationFramework

# Your code goes here.
Write-Output "Hello world"

$appName = AI_GetMsiProperty ProductName
$app = Get-CimInstance -ClassName Win32_Product | Where-Object {$_.Name -match "$appName"}

$msgBox = [System.Windows.MessageBox]::Show("You are about to uninstall version $($app.Version) of $appName. Do you want to proceed?",'Title Here', 4)

switch ($msgBox){

'Yes' {
# do something
}

'No' {
# do something
}
}
The above can be implemented in Advanced Installer as a custom action without sequence.

You can do so by going to "Custom Actions" page and adding a "Run PowerShell script inline" custom action, without sequence (by pressing the "Add custom action without sequence" button which is located to the right side of the custom action's name)

After doing so, we can now schedule the custom action as an "Init Event" on our first dialog. To achieve this, please go to "Dialogs" page --> select "WelcomeDlg" and, under "Init Events" tab, please add a new event as it follows:

Event: Execute custom action
Argument: PowerShellScriptInline
Condition: leave unchanged


This way, when the dialog is initialized, the custom action will be triggered. In the end, it will look something as it follows:

YesNo.png
YesNo.png (116.36 KiB) Viewed 2795 times
Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
EdwardSanchez
Posts: 2
Joined: Wed Jun 03, 2020 5:20 am

Re: My problem

Thanks @catalin for help, I have fixed the problem
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: My problem

Awesome news, Edward!

You are always welcome.

I am really glad you solved the problem.

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

Return to “Common Problems”