'*******************************************************************************************
'*
'* File Name:
'* ---------
'* $File$
'* $Revision$
'*
'* Purpose:
'* --------
'* Makes a call to FSCStarter.exe to trigger manual scan tasks
'*
'* Parameters:
'* -----------
'* ScanID
'* TextLog
'*
'* Parameter definitions:
'* ----------------------
'*
'* 1. The ID number of the Manual Scan Job
'*
'* 2. TextLog => defines whether this scripts logs entries to a text file under the local Forefront installation folder
'* Possible Values => true ; false
'*
'********************************************************************************************************
' Constant for controlling text file operations
Const FOR_READING = 1
' Constants registry
Const HIVE = "HKEY_LOCAL_MACHINE\"
Const REG_KEY = "SOFTWARE\Microsoft\Forefront Server Security\"
Const REG_KEY_64 = "SOFTWARE\Wow6432Node\Microsoft\Forefront Server Security\"
' Retrieve the local installation path of Forefront
ForefrontInstallPath = RetrieveRegValue (REG_KEY & "Exchange Server","InstalledPath", 1)
if IsNull(ForefrontInstallPath) then
ForefrontInstallPath = RetrieveRegValue (REG_KEY_64 & "Exchange Server","InstalledPath", 1)
end if
'If cannot find Forefront for Exchange, error out.
If IsNull(ForefrontInstallPath) Then
WriteMOMEvent "TASK ERROR: Unable to retrieve Forefront for Exchange installation path", 1
ScriptContext.Quit
End If
' Create Log folder under Forefront installation folder
If TextLogParameter = "true" then
CreateLogFolder()
End If
WriteLog "NULL"
WriteLog "Beginning Execution of Manual Scan Script"
strParam = " s" & ScanIDParameter
strCommand = """" & ForefrontInstallPath & "\FSCStarter.exe" & """"
intResult = ShellExecute(strCommand,strParam)
WriteLog "Initiating Manual Scan Job with ID = " & ScanIDParameter
'********************************************************************
'*
'* 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
Set objReg = Nothing
RetrieveRegValue = strRegValue
End Function
'***********************************************************************
'*
'* Function: ShellExecute()
'*
'* Purpose: Sets up call to ANTUTIL for switching hooking mode
'*
'***********************************************************************
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)
If TextLogParameter = "true" Then
Dim objfs
Dim objf
Dim strTimeStamp
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