icekid
Posts: 2
Joined: Wed Jan 11, 2017 4:27 pm

Overwirite PackageCode if older Version detected

Hy Advance installer Team
We have some Problem with the Update of your software. Since so we recomend the user to deinstall older version of your produckt first then install the newer version. But since User do what user do they sometimes ignore our recommndation and overinstall the newer version. We like to prevent that. The only thing i found out to prevent that is to overwrite the packagecode with the installed one so the msi installer acts like the already installed one. So hit the new Version should hit maintance,remove or repair on execxute if installed version is detected.

To do that i wrrote a script on place it on a costum action on run. who get the installed packagecode and try to set it but it seems not to work to set it right or to late ;/

MSI (c) (4C:6C) [13:20:09:366]: PROPERTY CHANGE: Adding CustomActionData property. Its value is 'Is64BitParamsScript$propValue = AI_GetMsiProperty [PackageCode]
$packageCodeOVersion=-1
$packageCodeOVersion= get-wmiobject Win32_Product -filter "name='ProducktName'" | Select-Object -ExpandProperty IdentifyingNumber

if(!$packageCodeOVersion -ne -1)
{
Write-Output "found old version"
Write-Output $packageCodeOVersion
Write-Output "Set Old Version to new installer to prenevt update deinstall old version first"
AI_SetMsiProperty [PackageCode] $packageCodeOVersion
}else{
Write-Output "No old version proceed like normal"
}
'.
Aktion beendet um 13:20:09: AI_DATA_SETTER_5. Rückgabewert 1.
MSI (c) (4C:6C) [13:20:09:366]: Doing action: SetVersion
Aktion 13:20:09: SetVersion.
Aktion gestartet um 13:20:09: SetVersion.
MSI (c) (4C:38) [13:20:09:366]: Invoking remote custom action. DLL: C:\Users\VMWare\AppData\Local\Temp\MSI1046.tmp, Entrypoint: RunPowerShellScript
MSI (c) (4C!CC) [13:20:17:571]: PROPERTY CHANGE: Adding [PackageCode] property. Its value is '{21FD8A1B-CB6A-4216-82E6-5A90B568CE0D}'.
Dumping PowerShell invoke log ...
--> Found PowerShell path: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
--> PowerShell Script Execution Result Code: 0
--> PowerShell Script Execution log:
found old version
{21FD8A1B-CB6A-4216-82E6-5A90B568CE0D}
Set Old Version to new installer to prenevt update deinstall old version first
MSI (c) (4C!CC) [13:20:17:571]: PROPERTY CHANGE: Adding POWERSHELL_EXECUTION_LOG property. Its value is 'found old version
{21FD8A1B-CB6A-4216-82E6-5A90B568CE0D}
Set Old Version to new installer to prenevt update deinstall old version first'.
Aktion beendet um 13:20:17: SetVersion. Rückgabewert 1.

i would need some help
Catalin
Posts: 6596
Joined: Wed Jun 13, 2018 7:49 am

Re: Overwirite PackageCode if older Version detected

Hello,

From what I can see in your PowerShell script, you have some mistakes in what regards the syntax.

The syntax for the AI_GetMsiProperty method is as it follows:

Code: Select all

$propValue = AI_GetMsiProperty PackageCode
not

Code: Select all

$propValue = AI_GetMsiProperty [PackageCode]
The same goes for the AI_SetMsiProperty method:

Code: Select all

AI_SetMsiProperty PackageCode $packageCodeOfVersion
instead of

Code: Select all

AI_SetMsiProperty [PackageCode] $packageCodeOVersion
Hope this helps.

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

Return to “Common Problems”