0

In Inno Setup I execute another setup file using this code:

[Run]
Filename: "{app}\MySetup2.exe"; WorkingDir: "{app}"; Flags: waituntilterminated

This setup file executes another setup file and closes itself. But Inno Setup does not wait for the second setup and goes to the "finish" dialog. How to pause the installation until this second setup is closed?

Inno Setup Exec() function Wait for a limited time shows how to wait for the process. But how to apply this during installation?

Ken White
  • 123,280
  • 14
  • 225
  • 444
Codename K
  • 890
  • 4
  • 23
  • 52
  • 2
    Start by double checking if the `MySetup2.exe` offers a way to wait for its child process. That's the only correct solution. What kind of installer is that? – Martin Prikryl Dec 28 '21 at 19:56
  • I do not think it has wait until terminated function. It is a VSTO Office Add-in Installer. – Codename K Dec 28 '21 at 20:01
  • 1
    I mean how was the installer made? Is it Inno Setup? (probably not) Install Shield? NSIS? WiX? – Martin Prikryl Dec 28 '21 at 20:09
  • The first installer looks like it is just a program that runs the second installer. – Codename K Dec 28 '21 at 20:32
  • 1
    So do you think it's custom made? Why don't you embed just the "second" installer into your Inno Setup installer, if you believe the first installer is useless? – Martin Prikryl Dec 29 '21 at 06:45

1 Answers1

0

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.

Codename K
  • 890
  • 4
  • 23
  • 52