Is there an easy way to convert these two functions to powershell functions?
Function checkProcessAndWait(strProcessName)
Dim i
' Check if setup is running
For i = 0 to 30
If isProcessRunning(strProcessName) Then
checkProcessAndWait = true
wscript.Sleep 2000 ' sleep two seconds between checks
Else
' setup isn't running, so continue install
checkProcessAndWait = false
If i <> 0 Then
' PropSetup process was running when the loop began, so a wait is necessary
wscript.Sleep 10000 ' wait ten seconds to make sure registry has a chance to update
End If
Exit For
End If
Next
End Function
Function isProcessRunning(strProcessName)
strComputer = "." ' local computer
Dim objWMIService, strWMIQuery
strWMIQuery = "Select * from Win32_Process where name like '" & strProcessName & "'"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
If objWMIService.ExecQuery(strWMIQuery).Count > 0 then
isProcessRunning = true
Else
isProcessRunning = false
End if
End Function