ForefrontInstallPath = RetrieveRegValue (REG_KEY & "Exchange Server","InstalledPath", 1)
if IsNull(ForefrontInstallPath) then
ForefrontInstallPath = RetrieveRegValue (REG_KEY_64 & "Exchange Server","InstalledPath", 1)
end if
If TextLogParameter = "true" then
CreateLogFolder(ForefrontInstallPath)
End If
WriteLog "NULL"
WriteLog "Beginning Execution of setting threshold value: " & ThresholdParameter
SetThreshold ThresholdParameter
if Err<>0 then
WriteLog "Execution of setting threshold value finished with uncatched error."
else
WriteLog "Execution of setting threshold value finished"
end if
ConfigXML = "<statisticsManager><fileFilterMatchAlert><enabled>1</enabled><hangoverTime>0</hangoverTime><slidingWindowLength>3600</slidingWindowLength><thresholdPercentage>" & Threshold & "</thresholdPercentage><thresholdValue>312</thresholdValue><type>7</type></fileFilterMatchAlert></statisticsManager>"
WriteLog ConfigXML
Set StatsServ = CreateObject("AntigenStatisticsService.StatisticsServ")
if (IsNull(StatsServ) or Err<>0) then
WriteMOMEvent "TASK ERROR: Unable To creat object AntigenStatisticsService.StatisticsServ", 1, CREAT_OBJECT_FAIL
WriteLog "Unable To creat object AntigenStatisticsService.StatisticsServ"
else
Err.Clear
StatsServ.ModifyStatsConfiguration(ConfigXML)
if Err<>0 then
WriteMOMEvent "TASK ERROR: Unable To set threshold", 1, MODIFY_CONFIG_FAIL
WriteLog "Unable To set threshold"
end if
end if
Dim objFSO
set objFSO = CreateObject ("Scripting.FileSystemObject")
If objFSO.FolderExists(ForefrontInstallPath & "\MOMLogs") = 0 then
objFSO.CreateFolder(ForefrontInstallPath & "\MOMLogs")
End If
Set objFSO = Nothing
End Function
'***********************************************************************
'*
'* Function: WriteLog()
'*
'* Purpose: Writes script activity and errors to a log file
'*
'***********************************************************************
Function WriteLog (strLogText)
On Error Resume Next
Err.Clear
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