I found a solution for this issue. You need to use a VBScript to run the first installer and make it wait for both first and second sub installer. It runs the first installer and wait until it is closed. Once closed the VBScript goes to the next code which checks for the process name of the second sub installer and waits until it is closed. You run this VBScript in the Inno Setup. Here is the the VBScript code which you need to save with file extension .vbs,
on error resume Next
Set objArgs = Wscript.Arguments
dim strArg0
strArg0 = objArgs(0)
strArg1 = objArgs(1)
Dim FSO, CurrentFolder
Set FSO = CreateObject("Scripting.FileSystemObject")
CurrentFolder = FSO.GetAbsolutePathName(".")
const DontWaitUntilFinished = false, ShowWindow = 1, DontShowWindow = 0, WaitUntilFinished = true
set oShell = WScript.CreateObject("WScript.Shell")
command = strArg0
oShell.Run command, ShowWindow, WaitUntilFinished
'''''''''''''''''''''''''''''''
if strArg1 <> "" then
strProcess = strArg1
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcesses = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = '"& strProcess &"'")
Do While colProcesses.Count > 0
Set colProcesses = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = '"& strProcess &"'")
Wscript.Sleep(1000) 'Sleep 1 second
Loop
end if
And this is the Inno Setup code which you put in the Run section (assuming you saved the VBScript file as MyVBS1.vbs),
[Run]
Filename: "wscript.exe"; Parameters: """{app}\MyVBS1.vbs"" ""{app}\MySetup2.exe"" ""MySubSetup.exe"""; Flags: waituntilterminated
wscript.exe
Runs the Windows Script Host
{app}\MyVBS1.vbs
The file location of VBScript file
{app}\MySetup2.exe
The file location of first installer
MySubSetup.exe
The process name of the second installer.