This is the story. I've written the below script to perform an installation (which will be done silently via SMS) and it
doesn't seem to wait until one installation is finished before it goes to the next.
What my intention is to do is to wait until the process irsetup.exe is no longer running before it moves to the next installation.
The original setup calls upon msiexec which calls upon irsetup.exe. If it tries to do all the setup at once, the setup fails and doesn't work.
Thanks.
Code:
'Option Explicit
Dim WshShell, WshFS
Dim objWMIService
Dim colProcesses
Dim ExePkg
Dim query
Dim SourcePath
Dim ProgramFilesDir
Dim SetupPackage
Dim IsAppInstalled
Dim ProcessThatDoesInstalling
Dim ProgMenu
Dim AllUsersStartMenu
'On Error Resume Next
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshFS = WScript.CreateObject ("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _ ("SELECT * FROM Win32_Process WHERE Name = '" query "'")
AllUsersStartMenu = WshShell.SpecialFolders("AllUsersStartMenu")
ProcessThatDoesInstalling = "Irsetup.exe"
ProgramFilesDir = WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ProgramFilesDir")
SourcePath = Left(WScript.ScriptFullName, Len(WScript.ScriptFullName) - Len(WScript.ScriptName))
IsAppInstalled = ProgramFilesDir & "\Early Years Maths Pack\eympmenu.exe"
SetupPackage = SourcePath & "Maths\setup1.exe /s"
ProgMenu = "\Early Years Maths Pack"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
IsAppInstalled = ProgramFilesDir & "\iR Games Pack Vol.1\menu.exe"
SetupPackage = SourcePath & "Games\PG1setup2.exe /s"
ProgMenu = "\iR Games Pack Vol.1"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
IsAppInstalled = ProgramFilesDir & "\iR Games Pack Vol.2\menu.exe"
SetupPackage = SourcePath & "Games\PG2setup2.exe /s"
ProgMenu = "\iR Games Pack Vol.2"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
IsAppInstalled = ProgramFilesDir & "\iR Games Pack Vol.3\menu.exe"
SetupPackage = SourcePath & "Games\PG3setup2.exe /s"
ProgMenu = "\iR Games Pack Vol.3"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
IsAppInstalled = ProgramFilesDir & "\iR Games Pack Vol.4\pg4menu.exe"
SetupPackage = SourcePath & "Games\PG4setup2.exe /s"
ProgMenu = "\iR Games Pack Vol.4"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
IsAppInstalled = ProgramFilesDir & "\iR Games Pack Vol.5\pg5menu.exe"
SetupPackage = SourcePath & "Games\PG5setup2.exe /s"
ProgMenu = "\iR Games Pack Vol.5"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
IsAppInstalled = ProgramFilesDir & "\iR Literacy Pack One\lp1menu.exe"
SetupPackage = SourcePath & "Literacy\setup.exe /s"
ProgMenu = "\iR Literacy Pack One"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
IsAppInstalled = ProgramFilesDir & "\Maths Pack 1\cdfiles\menu.exe"
SetupPackage = SourcePath & "Maths\setup1.exe /s"
ProgMenu = "\Maths Pack 1"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
IsAppInstalled = ProgramFilesDir & "\Maths Pack 2\menu.exe"
SetupPackage = SourcePath & "Maths\setup3.exe /s"
ProgMenu = "\Maths Pack 2"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
IsAppInstalled = ProgramFilesDir & "\Maths Pack 3\mp3menu.exe"
SetupPackage = SourcePath & "Maths\setup3.exe /s"
ProgMenu = "\Maths Pack 3"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
IsAppInstalled = ProgramFilesDir & "\Primary Games Vol.1\menu.exe"
SetupPackage = SourcePath & "Games\PG1setup.exe /s"
ProgMenu = "\Primary Games Vol.1"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
IsAppInstalled = ProgramFilesDir & "\Primary Games Vol.2\menu.exe"
SetupPackage = SourcePath & "Games\PG2setup.exe /s"
ProgMenu = "\Primary Games Vol.2"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
IsAppInstalled = ProgramFilesDir & "\Primary Games Vol.3\menu.exe"
SetupPackage = SourcePath & "Games\PG4setup.exe /s"
ProgMenu = "\Primary Games Vol.3"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
IsAppInstalled = ProgramFilesDir & "\Primary Games Vol.4\pg4menu.exe"
SetupPackage = SourcePath & "Games\PG4setup.exe /s"
ProgMenu = "\Primary Games Vol.4"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
IsAppInstalled = ProgramFilesDir & "\Primary Games Vol.5\pg5menu.exe"
SetupPackage = SourcePath & "Games\PG5setup.exe /s"
ProgMenu = "\Primary Games Vol.5"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
IsAppInstalled = ProgramFilesDir & "\Teaching Fractions\menu.exe"
SetupPackage = SourcePath & "Teaching\setup1.exe /s"
ProgMenu = "\Teaching Fractions"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
IsAppInstalled = ProgramFilesDir & "\Teaching Money\menu.exe"
SetupPackage = SourcePath & "Teaching\setup2.exe /s"
ProgMenu = "\Teaching Money"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
IsAppInstalled = ProgramFilesDir & "\Teaching Measures\menu.exe"
SetupPackage = SourcePath & "Teaching\setup3.exe /s"
ProgMenu = "\Teaching Measures"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
IsAppInstalled = ProgramFilesDir & "\Teaching Time\menu.exe"
SetupPackage = SourcePath & "Teaching\setup4.exe /s"
ProgMenu = "\Teaching Time"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
IsAppInstalled = ProgramFilesDir & "\Teaching Tables\menu.exe"
SetupPackage = SourcePath & "Teaching\setup5.exe /s"
ProgMenu = "\Teaching Tables"
call Install (IsAppInstalled, SetupPackage, ProgMenu)
Function Install (IsAppInstalled, SetupPackage, ProgMenu)
If Not WshFS.FileExists(IsAppInstalled) Then
Set ExePkg = WshShell.Exec(SetupPackage)
'Loop until irsetup starts
While (isprogramrunning(ProcessThatDoesInstalling) = 1)
Wscript.Sleep 100
Wend
' Loop until irsetup finishes
While (isprogramrunning(ProcessThatDoesInstalling) = 0)
Wscript.Sleep 100
Wend
End If
If Not WshFS.FolderExists(AllUsersStartMenu & "\Programs\iR") Then
WshFS.CreateFolder AllUsersStartMenu & "\Programs\iR"
End If
If WshFS.FolderExists(AllUsersStartMenu & "\Programs" & ProgMenu) Then
WshFS.MoveFolder AllUsersStartMenu & "\Programs" & ProgMenu, AllUsersStartMenu & "\Programs\iR" & ProgMenu
End If
End Function
Function isprogramrunning (ProcessThatDoesInstalling)
if colProcesses.count = 0 then
isprogramrunning = False
else
isprogramrunning = True
end if
End Function