jakub
Posts: 6
Joined: Thu Aug 26, 2021 9:53 am

Using PowerShell automation with multiple AI versions on the same host

Thu Aug 26, 2021 1:00 pm

I am using PowerShell automation script to adjust versioned folder name AIP project at build time:

Code: Select all

$advinst = New-Object -comobject AdvancedInstaller
$project = $advinst.LoadProject("$absoluteProjectPath")
$versionedFolder = $project.FoldersComponent.FindFolderByPath("APPDIR\agent\bin").Folders[0]
$versionedFolder.Name = "$ProjectVersion"
$project.Save()
I have two versions of AI installed on the building machine: 16.6.1 and 18.5. While trying to build with AI 16.6.1 after running the script above I get the following error:

Code: Select all

This project (fragment) was edited with a newer version of Advanced Installer (18.5) and cannot be loaded.
which means AI COM object in the script uses AI in version 18.5, not 16.6.1. Is there a way to tell the script which version of AI to use?

Liviu
Posts: 1026
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: Using PowerShell automation with multiple AI versions on the same host

Fri Aug 27, 2021 8:09 am

Hi and welcome to our forums,
which means AI COM object in the script uses AI in version 18.5, not 16.6.1. Is there a way to tell the script which version of AI to use?
AI COM uses the latest version installed on the system.
You need to register the AI version you want to use for COM, to do that, please follow these steps:
  1. Open an elevated Command Prompt.
  2. Use the following command:

    Code: Select all

    "C:\Program Files (x86)\Caphyon\Advanced Installer 16.6.1\bin\x86\advinst.exe" /REGSERVER
    Use upper-case letters for "/REGSERVER".
    If you want to use another AI version, just use the above command. Go to the version you want to use and you can find the advinst.exe in "\bin\x86\".
  3. Restart the PowerShell session and now you can build with the 16.6.1 version inside your script.
Hope this helps! If you have any other questions, please don't hesitate to contact us.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

jakub
Posts: 6
Joined: Thu Aug 26, 2021 9:53 am

Re: Using PowerShell automation with multiple AI versions on the same host

Tue Aug 31, 2021 7:21 am

Hi,

Thanks for quick reply.

So I've checked and it does not work for me. Actually I can see that the command modifies some registries (I can see in oleview.exe that COM object is registered correctly ), but still has no effect, even though I start a new PowerShell session each time. Additionally, while calling AI 16.6.1, only /RegServer do some changes, /REGSERVER has no effect at all.

BR,
Jakub

Liviu
Posts: 1026
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: Using PowerShell automation with multiple AI versions on the same host

Tue Aug 31, 2021 1:40 pm

Hi Jakub,

This is really strange.

Can you please make sure you are running an Command Prompt elevated?

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

jakub
Posts: 6
Joined: Thu Aug 26, 2021 9:53 am

Re: Using PowerShell automation with multiple AI versions on the same host

Tue Aug 31, 2021 2:08 pm

Hi Liviu,

alright, in elevated command prompt it works! I was misled by oleview.exe tool which somehow doesn't refresh the current state correctly.

Thanks,
Jakub

Liviu
Posts: 1026
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: Using PowerShell automation with multiple AI versions on the same host

Tue Aug 31, 2021 2:22 pm

You are always welcome!

I'm glad it works now! Please let us know if there is anything else we could help you with and we will gladly assist.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”