If IsNull(ForefrontInstallPath) Then
WriteMOMEvent "TASK ERROR: Unable To Retrieve Forefront for Exchange Installation Path", 1, INSTALL_PATH_FAIL
ScriptContext.Quit
End If
If TextLogParameter = "true" then
CreateLogFolder(ForefrontInstallPath)
End If
WriteLog "NULL"
WriteLog "Beginning Execution of RetrieveUpdateNumber Script to retrieve " & EngineName & " Update Number"
If EngineParameter = "null" or IsNull(EngineParameter) Then
Description = State.get("DescriptionParameter")
WriteLog "Engine Parameter is Null, Get Engine From State DescriptionParameter= " & Description
If Description = "null" or IsNull(Description)or Description="" or Description=" " or IsEmpty(Description) Then
WriteMOMEvent "TASK ERROR: ForefrontRetrieveEngineUpdateNumber ,Engine Param is not specified", 1, INSTALL_PATH_FAIL
ScriptContext.Quit
End If
EngineName = StripEngineName(Description)
WriteLog "Engine Name= " & EngineName
Else
EngineName = EngineParameter
End If
If EngineName = "null" or IsNull(EngineName) Then
WriteMOMEvent "TASK ERROR: ForefrontRetrieveEngineUpdateNumber ,Engine Param is not specified", 1, INSTALL_PATH_FAIL
ScriptContext.Quit
End If
UpdateRegPath = REG_KEY & InstalledProduct & "\Scan Engines\" & EngineName
ScriptContext.Sleep (15000)
'If Update number is null, the engine was not found in the registry
If IsNull(UpdateNumber) or UpdateNumber = "" Then
WriteLog "WARNING: " & EngineName & " engine was not found on " & ScriptContext.TargetComputer
WriteMOMEvent "WARNING: " & EngineName & " engine was not found on " & ScriptContext.TargetComputer & ". Update number could not be retrieved.", 2, NULL
ScriptContext.Quit
End If
WriteLog EngineName & " Update Version = '" & UpdateNumber & "'"
WriteMOMEvent EngineName & " Update Version = " & UpdateNumber, 4, ENG_UPDATE_NUM
WriteLog "Finished Execution of RetrieveUpdateNumber Script"
'********************************************************************
'*
'* Function: StripEngineName
'*
'* Purpose: Strips Engine Name from Event descrition Text
'*
'********************************************************************
Function StripEngineName (EventText)
If not (EventText = "null" or IsNull(EventText) or EventText="" or EventText=" ") Then
Dim objFSO
set objFSO = CreateObject ("Scripting.FileSystemObject")
If objFSO.FolderExists(ForefrontInstallPath & "\MOMLogs") = 0 then
objFSO.CreateFolder(ForefrontInstallPath & "\MOMLogs")
End If
Set objFSP = Nothing
End Function
'***********************************************************************
'*
'* Function: WriteLog()
'*
'* Purpose: Writes script activity and errors to a log file
'*
'***********************************************************************
Function WriteLog (strLogText)
Dim objfs
Dim objf
Dim strTimeStamp
If TextLogParameter = "true" Then
On Error Resume Next
Err.Clear
Set objfs = CreateObject("Scripting.FileSystemObject")
Set objf = objfs.OpentextFile(ForefrontInstallPath & "\MOMLogs\" & "Tasks.log", 8, False)
' If log file doesn't exist - create it
If Err.Number <> 0 Then
Set objf = objfs.CreatetextFile(ForefrontInstallPath & "\MOMLogs\" & "Tasks.log", False)
Err.Clear
End If
If strLogText = "NULL" then
objf.WriteLine("")
Else
strTimeStamp = Date & " " & Time & " "
objf.WriteLine(strTimeStamp & strLogText)
End If
End If
Set objfs = Nothing
Set objf = Nothing
End Function
'********************************************************************
'*
'* Function: RetrieveRegValue
'*
'* Purpose: Retrieves String Value from Registry
'*
'********************************************************************
Function RetrieveRegValue (Key, strValueName, intValueType)
' intValueType -> 1 = String Value
' -> 2 = DWORD Value
const HKEY_LOCAL_MACHINE = &H80000002
Dim strServerName
Dim objReg
Dim strRegValue
On Error Resume Next
Err.Clear
Set objReg=GetObject("winmgmts:\root\default:StdRegProv")
If Err.Number <> 0 Then
Err.Clear
strRegValue = NULL
Else
Select Case intValueType
Case 1
strErr = objReg.GetStringValue (HKEY_LOCAL_MACHINE, Key, strValueName, strRegValue)
Case 2
strErr = objReg.GetDWORDValue (HKEY_LOCAL_MACHINE, Key, strValueName, strRegValue)
End Select
' if reading the registry fails via wmi return error
If strErr <> 0 then
strRegValue = NULL
End If
End If