Run MSI after MSI via Custom Script

Use this forum to ask questions after your subscription maintenance expires or before you buy. Need information on licensing or pricing? Questions about a trial version? This is the right place for you. No scripting questions, please.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
This topic is 1 year and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
gitpowershelluser
Posts: 24
Last visit: Mon Feb 06, 2023 11:30 am
Has voted: 1 time

Run MSI after MSI via Custom Script

Post by gitpowershelluser »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build:latest
Operating system:21h2
PowerShell version(s):
32-bit version of software?

*** Please add details and screenshots as needed below. ***

I want to install a separate MySecond.MSI that I do include in my first MSI file. Either the build fails, or the second MSI never launches. Thoughts?
Snag_6956e85.png
Snag_6956e85.png (27.96 KiB) Viewed 7612 times
User avatar
Alexander Riedel
Posts: 8472
Last visit: Mon Mar 18, 2024 2:59 pm
Answers: 19
Been upvoted: 37 times

Re: Run MSI after MSI via Custom Script

Post by Alexander Riedel »

Run your installer with a log. That usually should give you a hint.
msiexec /i "C:\MyPackage\Example.msi" /L*V "C:\log\example.log"
You can do the same for your secondary installer to see if it gets even executed and fails or if it just never gets executed.
Most likely it fails because another installer is currently running.
Alexander Riedel
SAPIEN Technologies, Inc.
gitpowershelluser
Posts: 24
Last visit: Mon Feb 06, 2023 11:30 am
Has voted: 1 time

Re: Run MSI after MSI via Custom Script

Post by gitpowershelluser »

When I put quotes in, the build fails
error CNDL0104 : Not a valid source file; detail: 'C' is an unexpected token. Expecting white space. Line 80, position 264.
so whatever the character is after the first double quote, is the unexpected token.. If I run this

/i /quiet "C:\Utilities\MS1Number1Folder\Application Manager.msi" - fails to create MSI

/i /quiet C:\Utilities\MS1Number1Folder\Application Manager.msi - Creates the MSI , and launches MSIEXEC (like its waiting for args) after the first MSI goes through

I added in the logging, does not create log file in my C:\temp folder, even I remove the quotes
gitpowershelluser
Posts: 24
Last visit: Mon Feb 06, 2023 11:30 am
Has voted: 1 time

Re: Run MSI after MSI via Custom Script

Post by gitpowershelluser »

I also know the work around is to create a PS1 to call the MSI, but I feel like I shouldn't have to do that

Please note, I'm not experienced but know enough and your product is AMAZING
User avatar
Alexander Riedel
Posts: 8472
Last visit: Mon Mar 18, 2024 2:59 pm
Answers: 19
Been upvoted: 37 times

Re: Run MSI after MSI via Custom Script

Post by Alexander Riedel »

It's the Bermuda triangle of our MSI builder, the WiX Toolset and Windows Installer. :D
Try using single quotes instead of double quotes. The file for the WiX Toolset is XML and likely something does not get correctly encoded/decoded.
I will be looking into it from our end here.

In general, if you have to install two or more MSI files I personally would do it this way:
- Create a starter executable with some progress / activity indicators.
- Copy the MSI files needed from a network or online location as needed from that application.
- Check what needs to be installed and what not from that app.
- Install everything needed one by one, making sure no two instances of msiexec are running.

This gives you more control over what gets installed, you can check versions, runtimes, PowerShell version etc from that front end application.
You can add a check box to install with logging if your customer / client experiences problems.
Alexander Riedel
SAPIEN Technologies, Inc.
gitpowershelluser
Posts: 24
Last visit: Mon Feb 06, 2023 11:30 am
Has voted: 1 time

Re: Run MSI after MSI via Custom Script

Post by gitpowershelluser »

Thanks for looking into this!

I'm doing ok with using a PS1 to launch the second app which funny enough is my application starter/manager for my applications across business departments. Do you all do virtual consulting?
gitpowershelluser
Posts: 24
Last visit: Mon Feb 06, 2023 11:30 am
Has voted: 1 time

Re: Run MSI after MSI via Custom Script

Post by gitpowershelluser »

This is what's in my CA_InstallApplicationManager.PS1 for those looking to install an MSI that may already be installed, you can read more about the MSIEXEC install switches here

https://docs.microsoft.com/en-us/window ... nstallmode

This might not be best practice but here's where I am

I have two feature requests to add onto the backlog...
One click to Uninstall, Build All, Install - or like a CustomTool thats in the Build and Run section
Ability to hide the PowerShell CMD window. The command you run for MS1 ommits the -hidden parameter
  1. #Get MSIVersion since Windows wont allow it easily
  2. function Get-MsiVersion
  3. {
  4.     param (
  5.         [parameter(Mandatory = $true)]
  6.         [ValidateNotNullOrEmpty()]
  7.         [System.IO.FileInfo]$MSIPATH
  8.     )
  9.     if (!(Test-Path $MSIPATH.FullName))
  10.     {
  11.         throw "File '{0}' does not exist" -f $MSIPATH.FullName
  12.     }
  13.     try
  14.     {
  15.         $WindowsInstaller = New-Object -com WindowsInstaller.Installer
  16.         $Database = $WindowsInstaller.GetType().InvokeMember("OpenDatabase", "InvokeMethod", $Null, $WindowsInstaller, @($MSIPATH.FullName, 0))
  17.         $Query = "SELECT Value FROM Property WHERE Property = 'ProductVersion'"
  18.         $View = $database.GetType().InvokeMember("OpenView", "InvokeMethod", $Null, $Database, ($Query))
  19.         $View.GetType().InvokeMember("Execute", "InvokeMethod", $Null, $View, $Null) | Out-Null
  20.         $Record = $View.GetType().InvokeMember("Fetch", "InvokeMethod", $Null, $View, $Null)
  21.         $Version = $Record.GetType().InvokeMember("StringData", "GetProperty", $Null, $Record, 1)
  22.         return $Version
  23.     }
  24.     catch
  25.     {
  26.         throw "Failed to get MSI file version: {0}." -f $_
  27.     }
  28. }
  29. #EndFunction
  30.  
  31. $MSIPath = '.\Application Manager.msi'
  32. Write-Host "Installing Application Manager $(Get-MsiVersion -MSIPATH $MSIPath)"
  33. if (!(Test-Path 'C:\Utilities\Application Manager'))
  34. {
  35.     & $MSIPath
  36.     Write-Host "done..."
  37. }
  38. else
  39. {
  40.     Get-Process -Name 'Application Manager' -ErrorAction SilentlyContinue | Foreach-Object { $_.CloseMainWindow() }
  41.    
  42.     $InstallerArgs = @(
  43.         "/i"
  44.         "`".\Application Manager.msi`""
  45.         "REINSTALLMODE=oeau"
  46.         "/quiet"
  47.     )
  48.    
  49.     Start-Process -FilePath msiexec.exe -ArgumentList $InstallerArgs -Wait
  50.     Write-Host "done..."
  51. }
  52.  
This topic is 1 year and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.