Avatar of G_M
G_M
Flag for Australia asked on

VBScript - Running multiple MSIs with supporting files from different folder in same script

Hey guys,

I am writing a script that is supposed to call two MSIs in two different subfolders. This is necessary because whist these two MSIs are being run (one after the other) there is a splash screen that is displayed that needs to be closed after the MSIs are run.

Each MSI has supporting files and unfortunately because they are from the same application, the supporting file structures are the same, so they can't be put into the same folder to be executed.

The issue I am having is that when I execute an MSI it will start running, but error midway through because it cannot find the supporting files.

Is there a way to run these MSIs and have them recognise where they are being run from to pick up the remaining files (I hope that made sense).

Here's the part of my code that counts here:
Set objWShell = CreateObject("Wscript.Shell")
strFPInst = "C:\Windows\System32\Msiexec.exe /i FP4\ClientUpdate.msi /qn /l c:\build\logs\notesfp4.log"
strHFInst = "C:\Windows\System32\Msiexec.exe /i FP4_Hotfix\ClientUpdate.msi /qn /l c:\build\logs\notesfp4hotfix.log"

errCode = objWShell.Run(strFPInst, 1, True)
WScript.Sleep 10000
errCode = objWShell.Run(strHFInst, 1, True)

Open in new window

Hope someone can help.
Cheers,
G_M
VB ScriptWindows 7

Avatar of undefined
Last Comment
G_M

8/22/2022 - Mon
Meir Rivkin

Windows Installer only allows a single MSI to be installing at a time, so u can't run simultaneously multiple MSI installers.
so its gotta be a sequential installation.
G_M

ASKER
So this script does wait for on MSI to finish before running the second one. That is not the issue here, but thank you for the reply.
Meir Rivkin

what supporting files they are looking for?
can u copy the supporting files to the place the msi is run from?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
G_M

ASKER
The supporting files are already in the same folder as the MSI(s). The problem is that the script isn't on the same directory as the MSIs and therefor when the MSIis running, because it's not self contained, it can't find the rest of the files.

If I run  the script to the same directory as the MSI, it will execute fine.
ASKER CERTIFIED SOLUTION
RobSampson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Meir Rivkin

u have few options.
1. u can have the script copy it self to where the supporting files are and execute the MSI installers.
2. u can add installation folder when running the MSI installers.
add this parameter when running the MSI:
INSTALLDIR="<SupportingFilesDirectory">
3. you can have the script create separate, copy there the supporting files and the MSI installers and run them.
G_M

ASKER
@Sediwick, thanks for your response. I tried 2 and 3 of your options; however, they didn't do it for me. To be honest, the 1st option sounded a bit too hard for what it should be.

@robsampson, you were spot on with needing to switch the shell to the directory it needed to be in. I needed to do it twice though in order switch for both programs. I also added the "GetAbsolutePathName" to pck up the directory the script was running from. Thank you :o)

Here's my result:

Set objWShell = CreateObject("Wscript.Shell")
strCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
strFPInst = "C:\Windows\System32\Msiexec.exe /i ClientUpdate.msi /qn /l c:\build\logs\notesfp4.log"
strHFInst = "C:\Windows\System32\Msiexec.exe /i ClientUpdate.msi /qn /l c:\build\logs\notesfp4hotfix.log"

objWShell.CurrentDirectory = strCurPath & "\FP4"
errCode = objWShell.Run(strFPInst, 1, True)
WScript.Sleep 10000
objWShell.CurrentDirectory = strCurPath & "\FP4_Hotfix"
errCode = objWShell.Run(strHFInst, 1, True)

Open in new window

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.