我需要在主脚本的不同部分多次调用此函数。它只是查看是否安装了软件(将软件名称作为参数给出)。
这只是一段代码,也就是这个函数。它的远程方面工作正常。
'*************************************************************************
' This Subroutine checks if software is installed on system
'*************************************************************************
Sub CheckInstalledSoftware(item)
' This sub is VERY slow
blnCondition = False 'Simple check to see if software was found
WScript.Echo("Check if " & item & " is installed.")
WScript.Echo("------------------------------------")
Set colSoftware = objWMISrvc.ExecQuery("SELECT * FROM Win32_Product WHERE Name = '" & item & "'")
For Each objSoftware in colSoftware
If (objSoftware.InstallState = 5) Then
WScript.Echo(item & " is installed" & vbCrLf)
blnCondition = True
End If
Next
If blnCondition <> True Then
WScript.Echo(item & " is not installed" & vbCrLf)
End If
End Sub