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 IsNull(MOMInstallPath) Then
WriteMOMEvent "TASK ERROR: Unable To Retrieve MOM Agent Installation Path", 1, INSTALL_PATH_FAIL
ScriptContext.Quit
End If
' Create Log folder under Antigen installation folder
If TextLogParameter = "true" then
CreateLogFolder()
End If
WriteLog "NULL"
WriteLog "Beginning Execution of LicenseDeploy Script"
'Copy License.cfg file to the Antigen Installation folder
strParam = " l"
strCommand = """" & AntigenInstallPath & "\AntigenStarter.exe" & """"
intResult = ShellExecute(strCommand,strParam)
WriteLog "AntigenStarter has deployed the license.cfg file"
Else
WriteLog "ERROR: No license.cfg file is present for deployment"
WriteMOMEvent "TASK ERROR: No License.cfg file is present for deployment", 1, FILE_NOT_PRESENT
End If
'********************************************************************
'*
'* 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 LicenseFile
Dim objFSO
set objFSO = CreateObject ("Scripting.FileSystemObject")
LicenseFile = MOMPath & "Downloaded Files\" & ScriptContext.ManagementGroupName & "\License.cfg"
If objFSO.FileExists(LicenseFile) Then
objFSO.CopyFile LicenseFile, AntigenPath & "\", True
Set objFSO = Nothing
CopylicenseFile = True
Else
Set objFSO = Nothing
CopyLicenseFile = False
End If
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 & "\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