/bundles/itninjaweb/img/Breadcrumb_cap_w.png
Hi all,

Is there any way to check if the Windows Installer is already "installing" something?

Thanks!

Lewis
Answer Summary:
U can use this script '===================================== 'Begin: WaitIfSetupRunning ' '===================================== Private Sub WaitIfSetupRunning Dim SetupRunning:SetupRunning=False do until SetupRunning Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2") Set colProcesses=objWmiService.ExecQuery ("Select * From Win32_Process Where Name='msiexec.exe'") If (colProcesses.Count>0) Then For Each objProcess In colProcesses If (Instr (objProcess.Commandline,"/V")=0) Then Sleep 2000 Exit For Else If (colProcesses.Count=1) Then _ SetupRunning=True End If Next Else SetupRunning=True End If Loop End Sub '================================== 'Begin: Sleep ' ' This subroutine pauses script ' execution for specified amount of ' time in miliseconds. '================================== Private Sub Sleep (intTime) objShell.Run "ping 1.1.1.1 -n 1 -w " & intTime,0,True End Sub '================================== 'End: Sleep '==================================
Cancel
0 Comments   [ - ] Hide Comments

Comments

Please log in to comment

Community Chosen Answer


Answers

5
not sure if this is correct, but think there is a flag in the registry at HKLM\Software\Microsoft\Windows\Current Version\Installer\InProgress

can you confirm that?
Answered 03/22/2012 by: RaginX
Orange Belt

  • Good find @RaginX
    I indeed does make the above specified entry, giving the location of MSI from which it is being executed.
Please log in to comment
Answer this question or Comment on this question for clarity

Answers

1
Hey Lewis
U can use this script

'=====================================
'Begin: WaitIfSetupRunning
'
'=====================================


Private Sub WaitIfSetupRunning
Dim SetupRunning:SetupRunning=False
do until SetupRunning
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2")
Set colProcesses=objWmiService.ExecQuery ("Select * From Win32_Process Where Name='msiexec.exe'")
If (colProcesses.Count>0) Then
For Each objProcess In colProcesses
If (Instr (objProcess.Commandline,"/V")=0) Then
Sleep 2000
Exit For
Else
If (colProcesses.Count=1) Then _
SetupRunning=True
End If
Next
Else
SetupRunning=True
End If
Loop
End Sub


'==================================
'Begin: Sleep
'
' This subroutine pauses script
' execution for specified amount of
' time in miliseconds.
'==================================

Private Sub Sleep (intTime)
objShell.Run "ping 1.1.1.1 -n 1 -w " & intTime,0,True
End Sub


'==================================
'End: Sleep
'==================================
Answered 03/22/2012 by: harsh_k
Purple Belt

Please log in to comment
0
+1 for Answer, this would indeed be handy, if anyone knows a solution.
Answered 03/21/2012 by: Erroneus
Fifth Degree Black Belt

  • Btw. a rather crude solution, could maybe monitoring if msiexec is running, though that's _FAR_ from a perfect solution.
  • msiexec.exe can be running and not actually be *doing* anything. Thats the problem.

    I just started a new job packaging/customizing MSI's and I'm finding out the hard way that windows installer is a hard mistress :(
Please log in to comment