AntigenInstallPath = RetrieveRegValue (REG_KEY & "Antigen For Exchange","InstalledPath", 1)
InstalledProduct = "Antigen For Exchange"
If IsNull(AntigenInstallPath) Then
AntigenInstallPath = RetrieveRegValue (REG_KEY & "Antigen For SMTP","InstalledPath", 1)
InstalledProduct = "Antigen For SMTP"
End If
If IsNull(AntigenInstallPath) Then
WriteMOMEvent "TASK ERROR: Unable To Retrieve Antigen Installation Path", 1, INSTALL_PATH_FAIL
ScriptContext.Quit
End If
If EngineParameter = "null" Then
Description = State.get("DescriptionParameter")
EngineName = StripEngineName(Description)
Else
EngineName = EngineParameter
End If
If TextLogParameter = "true" then
CreateLogFolder(AntigenInstallPath)
End If
WriteLog "NULL"
WriteLog "Beginning Execution of RetrieveUpdateNumber Script to retrieve " & EngineName & " Update Number"
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)
i = 1
Do While Mid(EventText, i, 1) <> " "
i = i + 1
loop
FirstChar = i + 1
j = i
Do
j = j + 1
Loop Until Mid(EventText, j, 1) = " "
Dim objFSO
set objFSO = CreateObject ("Scripting.FileSystemObject")
If objFSO.FolderExists(AntigenInstallPath & "\MOMLogs") = 0 then
objFSO.CreateFolder(AntigenInstallPath & "\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(AntigenInstallPath & "\MOMLogs\" & "Tasks.log", 8, False)
' If log file doesn't exist - create it
If Err.Number <> 0 Then
Set objf = objfs.CreatetextFile(AntigenInstallPath & "\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