Antigen Manual Scan

Antigen_Manual_Scan.NoHost (WriteActionModuleType)

Triggers Manual Scan Job

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
InputTypeSystem.BaseData
Comment{2F5B0A74-2343-44C6-88C0-B3F89F3BC074}

Member Modules:

ID Module Type TypeId RunAs 
RunScriptAction WriteAction System.Mom.BackwardCompatibility.NoHost.ScriptResponse Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
ScanIDstring$Config/Parameters/ScanID$ScanIDID number of the Manual Scan Job
TextLogstring$Config/Parameters/TextLog$TextLogDefines whether a Text log file is written to

Source Code:

<WriteActionModuleType ID="Antigen_Manual_Scan.NoHost" Accessibility="Internal" Comment="{2F5B0A74-2343-44C6-88C0-B3F89F3BC074}">
<Configuration>
<IncludeSchemaTypes>
<SchemaType>MomBackwardCompatibility!System.Mom.BackwardCompatibility.AlertGenerationSchema</SchemaType>
</IncludeSchemaTypes>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="AlertGeneration" type="AlertGenerationType"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="InvokerType" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Parameters" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ScanID" type="xsd:string" minOccurs="0"/>
<xsd:element name="TextLog" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="ScanID" Selector="$Config/Parameters/ScanID$" ParameterType="string"/>
<OverrideableParameter ID="TextLog" Selector="$Config/Parameters/TextLog$" ParameterType="string"/>
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<WriteAction ID="RunScriptAction" TypeID="MomBackwardCompatibility!System.Mom.BackwardCompatibility.NoHost.ScriptResponse">
<AlertGeneration>$Config/AlertGeneration$</AlertGeneration>
<InvokerType>$Config/InvokerType$</InvokerType>
<Body><Script>

'*******************************************************************************************
'*
'* File Name:
'* ---------
'* AntigenManualScan.vbs
'* $Revision: 5 $
'*
'* Purpose:
'* --------
'* Makes a call to Antigenstarter.exe to trigger manual scan tasks
'*
'* Parameters:
'* -----------
'* ScanID
'* TextLog
'*
'* Parameter definitions:
'* ----------------------
'*
'* 1. The ID number of the Manual Scan Job
'*
'* 2. TextLog =&gt; defines whether this scripts logs entries to a text file under the local Antigen installation folder
'* Possible Values =&gt; true ; false
'*
'********************************************************************************************************

' Constant for controlling text file operations

Const FOR_READING = 1

' Constants registry

Const HIVE = "HKEY_LOCAL_MACHINE\"
Const REG_KEY = "SOFTWARE\Sybari Software\"


' Retrieve Script Parameters

ScanIDParameter = ScriptContext.Parameters.Get("ScanID")
TextLogParameter = ScriptContext.Parameters.Get("TextLog")

' Retrieve the local installation path of Antigen

AntigenInstallPath = RetrieveRegValue (REG_KEY &amp; "Antigen For Exchange","InstalledPath", 1)

'If cannot find Antigen for Exchange, error out.
If IsNull(AntigenInstallPath) Then
WriteMOMEvent "TASK ERROR: Unable to retrieve Antigen for Exchange installation path", 1
ScriptContext.Quit
End If

' Create Log folder under Antigen installation folder

If TextLogParameter = "true" then
CreateLogFolder()
End If

WriteLog "NULL"
WriteLog "Beginning Execution of Manual Scan Script"


strParam = " s" &amp; ScanIDParameter
strCommand = """" &amp; AntigenInstallPath &amp; "\AntigenStarter.exe" &amp; """"

intResult = ShellExecute(strCommand,strParam)

WriteLog "Initiating Manual Scan Job with ID = " &amp; ScanIDParameter




'********************************************************************
'*
'* Function: RetrieveRegValue
'*
'* Purpose: Retrieves String Value from Registry
'*
'********************************************************************

Function RetrieveRegValue (Key, strValueName, intValueType)

' intValueType -&gt; 1 = String Value
' -&gt; 2 = DWORD Value

const HKEY_LOCAL_MACHINE = &amp;H80000002
Dim strServerName
Dim objReg
Dim strRegValue


On Error Resume Next
Err.Clear
Set objReg=GetObject("winmgmts:\root\default:StdRegProv")
If Err.Number &lt;&gt; 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 &lt;&gt; 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
'*
'***********************************************************************

Function ShellExecute (Command, Parameter)

set wshShell = CreateObject ("wscript.shell")

wshShell.run Command &amp; Parameter,,false

Set wshShell = Nothing

End Function


'***********************************************************************
'*
'* Function: CreateLogFolder()
'*
'* Purpose: Creates Log subfolder under Antigen
'*
'***********************************************************************

Function CreateLogFolder ()

Dim objFSO
set objFSO = CreateObject ("Scripting.FileSystemObject")

If objFSO.FolderExists(AntigenInstallPath &amp; "\MOMLogs") = 0 then
objFSO.CreateFolder(AntigenInstallPath &amp; "\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(AntigenInstallPath &amp; "\MOMLogs\" &amp; "Tasks.log", 8, False)


' If log file doesn't exist - create it
If Err.Number &lt;&gt; 0 Then
Set objf = objfs.CreatetextFile(AntigenInstallPath &amp; "\MOMLogs\" &amp; "Tasks.log", False)
Err.Clear
End If

If strLogText = "NULL" then
objf.WriteLine("")
Else
strTimeStamp = Date &amp; " " &amp; Time &amp; " "
objf.WriteLine(strTimeStamp &amp; strLogText)
End If

Set objfs = Nothing
Set objf = Nothing
End If

End Function

'***********************************************************************
'*
'* Function: WriteMOMEvent()
'*
'* Purpose: Writes events to MOM EventLog
'*
'***********************************************************************

Function WriteMOMEvent(EventMessage, EventType)

Dim objEvt
Set objEvt = ScriptContext.CreateEvent

objEvt.Message = EventMessage
objEvt.EventType = EventType
ScriptContext.Submit(objEvt)

set objEvt = Nothing

End Function
</Script></Body>
<Language>VBScript</Language>
<Name>Antigen Manual Scan</Name>
<Parameters>
<Parameter>
<Name>ScanID</Name>
<Value>$Config/Parameters/ScanID$</Value>
</Parameter>
<Parameter>
<Name>TextLog</Name>
<Value>$Config/Parameters/TextLog$</Value>
</Parameter>
</Parameters>
<ManagementPackId>[Microsoft.Antigen.v9,,1.0.0.1]</ManagementPackId>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="RunScriptAction"/>
</Composition>
</Composite>
</ModuleImplementation>
<InputType>SystemLibrary!System.BaseData</InputType>
</WriteActionModuleType>