$WFBSHInstaller = "Agent_Installer.msi"
$pathOfWFBSHInstaller = "\\SERVER\netlogon\Kix32\Apps\TrendMicro"
$pathOfLocalWFBSHInstaller = "%USERPROFILE%\Kix32\Apps\TrendMicro"
$strComputer = "."
$strOutput = ""
$serviceCount = 0
$totalServiceCountToCheck = 3
; check if WFBS-SVR is installed by detecting service ntrtscan, tmlisten, svcGenericHost are exist or not
$objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + $strComputer + "\root\cimv2")
$colItems = $objWMIService.ExecQuery("Select * from Win32_Service")
For Each $objService in $colItems
$strOutput = $strOutput + $objService.name + @CRLF
Select
Case $objService.name = "ntrtscan"
$serviceCount = $serviceCount + 1
;? "Service " + $objService.Caption + " is " + $objService.Started
Case $objService.name = "tmlisten"
$serviceCount = $serviceCount + 1
;? "Service " + $objService.Caption + " is " + $objService.Started
Case $objService.name = "svcGenericHost"
$serviceCount = $serviceCount + 1
;? "Service " + $objService.Caption + " is " + $objService.Started
EndSelect
Next
If $serviceCount <> $totalServiceCountToCheck
Copy $pathOfWFBSHInstaller+"\"+$WFBSHInstaller $pathOfLocalWFBSHInstaller
Shell "msiexec /qn /i "+$pathOfLocalWFBSHInstaller+"\"+$WFBSHInstaller
If @error
"the installer failed with error:" @error
get $
Endif
EndIf