PowerShell Inline Custom Action - Currect Installation Task - Advanced Installer Community
coroberti
Posts: 18
Joined: Sun Jan 19, 2020 4:11 pm

PowerShell Inline Custom Action - Currect Installation Task

Hi,
Is there a way to figure out in PowerShell Inline Custom Action
what is doing the installer - installing, uninstalling, updating, etc.?

Alternatively, is there a way to get the msiexec command line and its switches passed
like /i or /x, etc.?

Thanks in advance.

Kind regards,
Robert
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: PowerShell Inline Custom Action - Currect Installation Task

Hello Robert,
Alternatively, is there a way to get the msiexec command line and its switches passed
like /i or /x, etc.?
This may indeed be possible, but unfortunately I am not aware of any method in which you can achieve it.
Is there a way to figure out in PowerShell Inline Custom Action
what is doing the installer - installing, uninstalling, updating, etc.?
Yes, there is a way. We can achieve this through Windows Installer properties. For instance, the properties for your scenarios are:

- Installed ---> Here, we play around the fact that either this property exists (has a value) or not (doesn't have a value). For installed, the condition for a first time install is:

Code: Select all

NOT Installed
Basically, the above condition means the "Installed" property does not exist.

We can do something similar in PowerShell, as it follows:

Code: Select all

$installed = AI_GetMsiProperty Installed

if ($installed -eq ""){

# this means that a first time install is happening

}
- REMOVE ---> The basic condition for uninstall is:

Code: Select all

REMOVE = "ALL"
With this in mind, we can achieve the same behavior in PowerShell, as it follows:

Code: Select all

$remove = AI_GetMsiProperty REMOVE

if($remove = "ALL"){

# this means an uninstall is happening

}
- OLDPRODUCTS ---> This is a property that is set only during an upgrade. The condition for an upgrade is:

Code: Select all

OLDPRODUCTS
(basically, the property exists)

We can achieve the same in PowerShell, as it follows:

Code: Select all

$oldproducts = AI_GetMsiProperty OLDPRODUCTS

if ($oldproducts -neq ""){

# this means an upgrade is performed

}
Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
coroberti
Posts: 18
Joined: Sun Jan 19, 2020 4:11 pm

Re: PowerShell Inline Custom Action - Currect Installation Task

Dear Catalin,
These are definitely helpful guidelines.

Thank you!

Kind regards,
Robert
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: PowerShell Inline Custom Action - Currect Installation Task

You are always welcome, Robert!

I am really glad I could help.

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

Return to “Common Problems”