nskris
Posts: 21
Joined: Fri Oct 26, 2018 3:32 pm

Install another software using attached powershell script

Hi,

I have written commands to first uninstall a software and install a upgraded version of the software using msiexec command in powershell script. This powershell script is then used in the custom action page under Run powershell script option. I have verified that when the powershell script is executed manually, the software gets uninstalled and then gets installed. But when i try to run the powershell script from MSI generated from advanced installer, it is throwing an error saying-MainEngineThread is returning 1618.
Please let me know how to to go about this issue.

regards,
Krishna
Catalin
Posts: 7845
Joined: Wed Jun 13, 2018 7:49 am

Re: Install another software using attached powershell script

Hello Krishna,

I am not sure why this happens. Could you please give me some more details about how you have configure your custom action (for instance, few screenshots)? Is your PowerShell script added as a script file or as an inline script?

Also, when is your custom action scheduled?

Looking forward to hearing from you.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
nskris
Posts: 21
Joined: Fri Oct 26, 2018 3:32 pm

Re: Install another software using attached powershell script

Hi Catalin,

PFA the screen shot of the AI setup. Iam using the Run powershell script file custom action and running the powershell script during installation.
The software iam trying to install is also an msi.

regards,
Krishna
Attachments
AIIssue.PNG
AIIssue.PNG (118.67 KiB) Viewed 20721 times
Catalin
Posts: 7845
Joined: Wed Jun 13, 2018 7:49 am

Re: Install another software using attached powershell script

Hello Krishna,

Thanks for the provided screenshot.

That is mainly happening due to the fact that you are running your custom action on deferred stage.

As you may already know, the deferred (during the "InstallExecution" stage) stage represents the stage where the system is being modified (files are copied/installed, registries are changed, etc.). Also, the Windows Installer does not allow two installation processes to be happening at the same time (e.g. you can not install two setups at the same time, the installation process of the first setup must first ends in order for the installation process of the second setup to start).

This is the reason why you are getting the "MainEngineThread returns 1618" error. This error can be translated to this:

Another installation is already in progress. Complete that installation before proceeding with this install.

I can understand why you have chosen to schedule your action like this (because your script file is copied on the target machine during the "Add Resources" action group, on deferred).

However, there is a solution which should satisfy your needs here. The solution would be to make use of the temporary files. Unlike Advanced Installer's regular files or resources, "Temporary Files" are copied on the target machine at the beginning of the installation and are deleted at the end of it, ensuring you have access to them throughout the entire install process.

Short, "Temporary Files" are copied during the CostFinalize standard action, at the beginning of the setup and removed during the InstallFinalize standard action.

With that being said, a workaround would be to add your script file (.ps1 file) as a temporary file in the "Files and Folders" page. This can be easily done by going to "Files and Folders" page and pressing the "Add temporary file" button from the toolbar. After doing so, double click on the added script file an take its property from the "Property:" field. The property should look something like this:

AI_YOURSCRIPT.PS1

Also, one more important thing would be to check the "Do not remove the file when setup ends" option.

Now, in your PowerShell script, in the "File path:" field, you can use the earlier copied property.

Now that we have configured the custom action, it is time to schedule it accordingly. In order to make this work, you can schedule it after the "Finish Execution" action group in the "Install Execution Stage". Also, one important thing is to uncheck the two options from the "Execution Options" section:

1. "Wait for custom action to finish before proceeding"

If this option is unchecked, the "Fail installation if custom action returns an error" will transform into:

2. "Wait for return code at the end of the sequence"

Also, another way would be to use an inline script instead.

Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
nskris
Posts: 21
Joined: Fri Oct 26, 2018 3:32 pm

Re: Install another software using attached powershell script

Thanks for replying. I will try these steps and keep you posted.

regards,
Krishna
Catalin
Posts: 7845
Joined: Wed Jun 13, 2018 7:49 am

Re: Install another software using attached powershell script

Hello Krishna,

You are always welcome.

Sure, please keep me updated about how this works for you.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
nskris
Posts: 21
Joined: Fri Oct 26, 2018 3:32 pm

Re: Install another software using attached powershell script

Hi Catalin,

I created a new MSI with only the powershell script execution to check the solution. As suggested by you, i created the Run powershell script custom action to Finish execution stage. I unchekced the two check boxes. PFA the screenshot. Iam still getting the same error when the other MSI gets initiated.

regards,
Krishna
Attachments
AIIssue-2.PNG
AIIssue-2.PNG (100.49 KiB) Viewed 20690 times
Catalin
Posts: 7845
Joined: Wed Jun 13, 2018 7:49 am

Re: Install another software using attached powershell script

Hello Krishna,

This is a strange behavior. In order for me to further investigate this, could you please forward me, by e-mail at support at advancedinstaller dot com, the following:

- the .AIP file used to build your setup.

- a download link for the setup

- a download ink for the older and newer versions of the setup that you are trying to install / uninstall

Also, please find attached a .zip file in which you can find the following:

- 2 test MSIs (test and tes2)

- the .aip file used to build the setup (which contains only the script)

- the script file

- the final setup

https://drive.google.com/file/d/1-YyY4x ... sp=sharing

Here is how you can test this:

Simply install "test.msi" on your test machine (e.g. Virtual Machine), then deploy the main setup ("script.exe"). script.exe contains the PowerShell script which will uninstall "test.msi" (silently) and then install "test2.msi" (silently).

Looking forward to hearing from you.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
nskris
Posts: 21
Joined: Fri Oct 26, 2018 3:32 pm

Re: Install another software using attached powershell script

Hi Catalin,

Thank you. I first ran the test.msi and ensured that it is installed. Now when i run the setup.exe, i see a windows install coordinator screen and the second MSI does not get triggered. I have sent the mail to support@advancedinstaller.com with required files of my setup.
Please let me know how it goes.

regards,
Krishna
Catalin
Posts: 7845
Joined: Wed Jun 13, 2018 7:49 am

Re: Install another software using attached powershell script

Hello Krishna,

Thanks for the sent files. I will have a look over them as soon as possible.

In what regards the fact that the second setup is not triggered, did you modify the path to the .MSI file to be launched from within the PowerShell script? By default, the script points to my desktop location and you have to modify that and then rebuild the project. To do so, simply SHIFT+right click on the .MSI file --> copy file location --> right click on the .ps1 file --> "Edit" and then replace the path to the MSI file to be installed --> save the .ps1 file and then try to rebuild the project I have sent you.

I apologize for not mentioning this in my last thread.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
nskris
Posts: 21
Joined: Fri Oct 26, 2018 3:32 pm

Re: Install another software using attached powershell script

Hi Catalin,

What i mean is, after kicking of the setup.exe, the uninstall did not proceed. It presents a Windows Install Coordinator. Also i am unable to build MSI project as it was built using architect edition and i am using enterprise edition.

regards,
Krishna
Catalin
Posts: 7845
Joined: Wed Jun 13, 2018 7:49 am

Re: Install another software using attached powershell script

Hello Krishna,

First of all, thanks for the provided files.

After further investigating this on our end, this seems indeed to be cause by a bug in our application. The root cause of this problem relies in the fact that the "Wait for custom action to finish before proceeding" flag ("Custom Actions" page --> your custom action --> "Execution Options" section) is ignored for our predefined PowerShell custom actions.

As a workaround, we can proceed as it follows: we will have a .BAT file which will launch the powershell.exe process, which will them launch our script into execution. The .BAT file content will be as it follows:

Code: Select all

powershell.exe -ExecutionPolicy Bypass -File "C:\Temp\SoftwareInstall.ps1"
After creating the .BAT file, it is time to add it in your project (in "Files and Folders" page). After doing so, let's create the custom action that will launch our .BAT file. To do so, please go to "Custom Actions" page and add a "Launch File" custom action with sequence. The custom action should look something as it follows:
CA.PNG
CA.PNG (54.33 KiB) Viewed 20599 times
In what regards the bug, I will let you know by updating this thread as soon as it will be fixed. Unfortunately, as for this moment, I am afraid I can not give you any ETA on when this will be fixed.

Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
nskris
Posts: 21
Joined: Fri Oct 26, 2018 3:32 pm

Re: Install another software using attached powershell script

Hi Catalin,

Thank you for the workaround. Although the workaround worked in that MSI, When i incorporate the same logic in the main MSI, I am getting a different error now. I find below error in the MSI log of the software that MSI is trying to install-
MSI (c) (68:0C) [08:10:10:201]: Client-side and UI is none or basic: Running entire install on the server.
MSI (c) (68:0C) [08:10:13:204]: Failed to grab execution mutex. System error 258.
Can you please suggest what i might be missing?
I have attached the screen shot.

Regards,
Krishna
Attachments
AIIssue-4.PNG
AIIssue-4.PNG (95.07 KiB) Viewed 20586 times
Catalin
Posts: 7845
Joined: Wed Jun 13, 2018 7:49 am

Re: Install another software using attached powershell script

Hello Krishna,

I am sad to hear that it did not work in your main project. The reason seems to be almost the same. The second MSI seems to be unable to grab the mutex due to the fact that there is another installation in progress.

Can you please try to add a timeout in your .BAT file (around 5 seconds, let's say) and see if that helps? This can be done by adding the following line to your .BAT file (before every other line of code):

Code: Select all

timeout 5

// rest of code below
If that does not help, could you please forward me a copy of your .AIP file by e-mail at support at advancedinstaller dot com so I can further investigate this?

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
nskris
Posts: 21
Joined: Fri Oct 26, 2018 3:32 pm

Re: Install another software using attached powershell script

Hi Catalin,
I was able to get the root cause of the issue. The main MSI has a chained MSI which might be interfering with the software MSI installation. I was able to replicate this issue using the POC MSI that i had shared with you earlier. I have now created a new MSI-MSI2 and added it as a chained package to MSI1. I then incorporated the bat file changes you had suggested. It resulted in the error of "Failed to grab execution mutex. System error 258.". I will share the mail containing the link of project files. Please let me know if there is a way around this issue.

regards,
Krishna

Return to “Common Problems”