Tasks for Documentum Agent on Node

ComTrade.EMC.Documentum.Windows.PA.MPAgent.Task (ProbeActionModuleType)

Performs variosu task related to documentum agent on node, like start, stop service, get status of service.

Element properties:

TypeProbeActionModuleType
IsolationAny
AccessibilityPublic
RunAsDefault
InputTypeSystem.BaseData
OutputTypeSystem.CommandOutput

Member Modules:

ID Module Type TypeId RunAs 
executeScript ProbeAction System.CommandExecuterProbe Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
ManagementServerstring$Config/ManagementServer$Management ServerIn case that ComTrade Documentum Management Pack is installed on another Management Server or Management Server not resolved set it to valid managemnt group name. This is network name of the Management Server host.
Argumentsstring$Config/Arguments$ArgumentsCustom arguments for a task.

Source Code:

<ProbeActionModuleType ID="ComTrade.EMC.Documentum.Windows.PA.MPAgent.Task" Accessibility="Public" Batching="true" PassThrough="false">
<Configuration>
<xsd:element minOccurs="1" name="Action" type="xsd:string"/>
<xsd:element minOccurs="1" name="Arguments" type="xsd:string"/>
<xsd:element minOccurs="1" name="ManagementServer" type="xsd:string"/>
<xsd:element minOccurs="1" name="TargetComputer" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="ManagementServer" Selector="$Config/ManagementServer$" ParameterType="string"/>
<OverrideableParameter ID="Arguments" Selector="$Config/Arguments$" ParameterType="string"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="executeScript" TypeID="System!System.CommandExecuterProbe">
<ApplicationName>%windir%\system32\cscript.exe</ApplicationName>
<WorkingDirectory/>
<CommandLine>//NoLogo $File/CTDmMPDocumentumAgentTasksDataProv.vbs$ "$Config/Action$" "$Config/Arguments$" "$Config/ManagementServer$" "$Target/ManagementGroup/Name$" "$Config/TargetComputer$"</CommandLine>
<TimeoutSeconds>900</TimeoutSeconds>
<RequireOutput>true</RequireOutput>
<Files>
<File>
<Name>CTDmMPDocumentumAgentTasksDataProv.vbs</Name>
<Contents><Script>
REM Implements Service Start/Stop/Status and Support tools
Option Explicit
SetLocale("en-us")
Call TasksMain()

Class CTRegistry

Private m_ErrorCode
Private m_ErrorDescription
Private m_ObjReg

Private M_HKEY_CLASSES_ROOT
Private M_HKEY_CURRENT_USER
Private M_HKEY_LOCAL_MACHINE
Private M_HKEY_USERS
Private M_HKEY_CURRENT_CONFIG
Private M_HKEY_DYN_DATA

Private M_REG_SZ
Private M_REG_EXPAND_SZ
Private M_REG_BINARY
Private M_REG_DWORD
Private M_REG_DWORD_BIG_ENDIAN
Private M_REG_LINK
Private M_REG_MULTI_SZ
Private M_REG_RESOURCE_LIST
Private M_REG_FULL_RESOURCE_DESCRIPTOR
Private M_REG_RESOURCE_REQUIREMENTS_LIST
Private M_REG_QWORD
Private M_REG_KEY_QUERY_VALUE
Private M_REG_KEY_SET_VALUE
Private M_REG_KEY_CREATE_SUB_KEY
Private M_REG_KEY_DELETE

Private m_Hostname

Private Sub ResetErrors()
m_ErrorCode = 0
m_ErrorDescription = vbNullString
Err.Clear
End Sub

Public Property Get HKEY_CLASSES_ROOT()
HKEY_CLASSES_ROOT=M_HKEY_CLASSES_ROOT
End Property

Public Property Get HKEY_CURRENT_USER()
HKEY_CURRENT_USER=M_HKEY_CURRENT_USER
End Property

Public Property Get HKEY_LOCAL_MACHINE()
HKEY_LOCAL_MACHINE=M_HKEY_LOCAL_MACHINE
End Property

Public Property Get HKEY_USERS()
HKEY_USERS=M_HKEY_USERS
End Property

Public Property Get HKEY_CURRENT_CONFIG()
HKEY_CURRENT_CONFIG=M_HKEY_CURRENT_CONFIG
End Property

Public Property Get HKEY_DYN_DATA()
HKEY_DYN_DATA=M_HKEY_DYN_DATA
End Property

Public Property Get REG_SZ()
REG_SZ=M_REG_SZ
End Property

Public Property Get REG_EXPAND_SZ()
REG_EXPAND_SZ=M_REG_EXPAND_SZ
End Property

Public Property Get REG_BINARY()
REG_BINARY=M_REG_BINARY
End Property

Public Property Get REG_DWORD()
REG_DWORD=M_REG_DWORD
End Property

Public Property Get REG_DWORD_BIG_ENDIAN()
REG_DWORD_BIG_ENDIAN=M_REG_DWORD_BIG_ENDIAN
End Property

Public Property Get REG_LINK()
REG_LINK=M_REG_LINK
End Property

Public Property Get REG_MULTI_SZ()
REG_MULTI_SZ=M_REG_MULTI_SZ
End Property

Public Property Get REG_RESOURCE_LIST()
REG_RESOURCE_LIST=M_REG_RESOURCE_LIST
End Property

Public Property Get REG_FULL_RESOURCE_DESCRIPTOR()
REG_FULL_RESOURCE_DESCRIPTOR=M_REG_FULL_RESOURCE_DESCRIPTOR
End Property

Public Property Get REG_RESOURCE_REQUIREMENTS_LIST()
REG_RESOURCE_REQUIREMENTS_LIST=M_REG_RESOURCE_REQUIREMENTS_LIST
End Property

Public Property Get REG_QWORD()
REG_QWORD=M_REG_QWORD
End Property

Public Property Get REG_KEY_QUERY_VALUE()
REG_KEY_QUERY_VALUE=M_REG_KEY_QUERY_VALUE
End Property

Public Property Get REG_KEY_SET_VALUE()
REG_KEY_SET_VALUE=M_REG_KEY_SET_VALUE
End Property

Public Property Get REG_KEY_CREATE_SUB_KEY()
REG_KEY_CREATE_SUB_KEY=M_REG_KEY_CREATE_SUB_KEY
End Property

Public Property Get REG_KEY_DELETE()
REG_KEY_DELETE=M_REG_KEY_DELETE
End Property

Public Function GetStringValue(ByVal sHive, ByVal sRegKey, ByVal sKeyName, ByRef oValue)
On Error Resume Next
Dim aValueTypes
Call ResetErrors
GetStringValue = False
If m_ObjReg.GetStringValue(sHive, sRegKey, sKeyName, oValue) = 0 Then
GetStringValue = True
Else
GetStringValue = False
End If
If Err.Number &lt;&gt; 0 Then
GetStringValue = False
m_ErrorCode = Err.Number
m_ErrorDescription = Err.Description
Err.Clear
End If
On Error Goto 0
End Function

Public Function GetExpandedStringValue(ByVal sHive, ByVal sRegKey, ByVal sKeyName, ByRef oValue)
On Error Resume Next
Dim aValueTypes
Call ResetErrors
GetExpandedStringValue = False
If m_ObjReg.GetExpandedStringValue(sHive, sRegKey, sKeyName, oValue) = 0 Then
GetExpandedStringValue = True
Else
GetExpandedStringValue = False
End If
If Err.Number &lt;&gt; 0 Then
GetExpandedStringValue = False
m_ErrorCode = Err.Number
m_ErrorDescription = Err.Description
Err.Clear
End If
On Error Goto 0
End Function

Public Function GetBinaryValue(ByVal sHive, ByVal sRegKey, ByVal sKeyName, ByRef oValue)
On Error Resume Next
Dim aValueTypes
Call ResetErrors
GetBinaryValue = False
If m_ObjReg.GetBinaryValue(sHive, sRegKey, sKeyName, oValue) = 0 Then
GetBinaryValue = True
Else
GetBinaryValue = False
End If
If Err.Number &lt;&gt; 0 Then
GetBinaryValue = False
m_ErrorCode = Err.Number
m_ErrorDescription = Err.Description
Err.Clear
End If
On Error Goto 0
End Function

Public Function GetDwordValue(ByVal sHive, ByVal sRegKey, ByVal sKeyName, ByRef oValue)
On Error Resume Next
Dim aValueTypes
Call ResetErrors
GetDwordValue = False
If m_ObjReg.GetDWORDValue(sHive, sRegKey, sKeyName, oValue) = 0 Then
GetDwordValue = True
Else
GetDwordValue = False
End If
If Err.Number &lt;&gt; 0 Then
GetDwordValue = False
m_ErrorCode = Err.Number
m_ErrorDescription = Err.Description
Err.Clear
End If
On Error Goto 0
End Function

Public Function GetQwordValue(ByVal sHive, ByVal sRegKey, ByVal sKeyName, ByRef oValue)
On Error Resume Next
Dim aValueTypes
Call ResetErrors
GetQwordValue = False
If m_ObjReg.GetQWORDValue(sHive, sRegKey, sKeyName, oValue) = 0 Then
GetQwordValue = True
Else
GetQwordValue = False
End If
If Err.Number &lt;&gt; 0 Then
GetQwordValue = False
m_ErrorCode = Err.Number
m_ErrorDescription = Err.Description
Err.Clear
End If
On Error Goto 0
End Function

Public Function GetMultiStringValue(ByVal sHive, ByVal sRegKey, ByVal sKeyName, ByRef oValue)
On Error Resume Next
Dim aValueTypes
Call ResetErrors
GetMultiStringValue = False
If m_ObjReg.GetMultiStringValue(sHive, sRegKey, sKeyName, oValue) = 0 Then
GetMultiStringValue = True
Else
GetMultiStringValue = False
End If
If Err.Number &lt;&gt; 0 Then
GetMultiStringValue = False
m_ErrorCode = Err.Number
m_ErrorDescription = Err.Description
Err.Clear
End If
On Error Goto 0
End Function

Public Function CheckPermission(ByVal sHive, ByVal sRegKey, ByVal oPermission, ByRef oGranted)
On Error Resume Next
Call ResetErrors
CheckPermission = False
If m_ObjReg.CheckAccess(sHive, sRegKey, oPermission, oGranted) = 0 Then
CheckPermission = True
Else
CheckPermission = False
End If
If Err.Number &lt;&gt; 0 Then
CheckPermission = False
m_ErrorCode = Err.Number
m_ErrorDescription = Err.Description
Err.Clear
End If
On Error Goto 0
End Function

Public Function EnumerateValues(ByVal sHive, ByVal sRegKey, ByRef oValue)
On Error Resume Next
Dim aValueTypes
Call ResetErrors
EnumerateValues = False
If m_ObjReg.EnumValues(sHive, sRegKey, oValue, aValueTypes) = 0 Then
EnumerateValues = True
Else
EnumerateValues = False
End If
If Err.Number &lt;&gt; 0 Then
EnumerateValues = False
m_ErrorCode = Err.Number
m_ErrorDescription = Err.Description
Err.Clear
End If
On Error Goto 0
End Function

Public Function EnumerateSubKeys(ByVal sHive, ByVal sRegKey, ByRef oValue)
On Error Resume Next
Call ResetErrors
EnumerateSubKeys = False
If m_ObjReg.EnumKey(sHive, sRegKey, oValue) = 0 Then
EnumerateSubKeys = True
Else
EnumerateSubKeys = False
End If
If Err.Number &lt;&gt; 0 Then
EnumerateSubKeys = False
m_ErrorCode = Err.Number
m_ErrorDescription = Err.Description
Err.Clear
End If
On Error Goto 0
End Function

Private Function Contains (ByVal arrValues, ByVal sFind)
On Error Resume Next
Contains = False
If Not IsNull(arrValues) Then
If Not (arrValues Is Nothing) Then
Dim tValue
For Each tValue In arrValues
If tValue = sFind Then
Contains = True
Exit For
End If
Next
End If
End If
On Error Goto 0
End Function

Public Function FindKey(ByVal sHive, ByVal sRegKey, ByVal sFindKey, ByRef oValue)
On Error Resume Next
Call ResetErrors
FindKey = False
Dim rtVals
If m_ObjReg.EnumKey(sHive, sRegKey, rtVals) = 0 Then
If Contains(rtVals, sFindKey) Then
FindKey = True
oValue = sRegKey &amp; "\" &amp; sFindKey
Else
If Not IsNull(rtVals) Then
Dim ky, rtVal
For Each ky in rtVals
If Not (ky Is Nothing) Then
If FindKey(sHive, sRegKey &amp; "\" &amp; ky, sFindKey, rtVal) Then
FindKey = True
oValue = rtVal
Exit For
End If
End If
Next
End If
End If
Else
FindKey = False
End If
If Err.Number &lt;&gt; 0 Then
FindKey = False
m_ErrorCode = Err.Number
m_ErrorDescription = Err.Description
Err.Clear
End If
On Error Goto 0
End Function

Public Function FindValue(ByVal sHive, ByVal sRegKey, ByVal sFindValue, ByRef oValue)
On Error Resume Next
Call ResetErrors
FindValue = False
Dim rtVals
If m_ObjReg.EnumValues(sHive, sRegKey, rtVals) = 0 Then
If Contains(rtVals, sFindValue) Then
FindValue = True
oValue = sRegKey
Else
Dim ky, rtVal
If m_ObjReg.EnumKey(sHive, sRegKey, rtVals) = 0 Then
If Not IsNull(rtVals) Then
For Each ky In rtVals
If Not (ky Is Nothing) Then
If FindValue(sHive, sRegKey &amp; "\" &amp; ky, sFindValue, rtVal) Then
FindValue = True
oValue = rtVal
Exit For
End If
End If
Next
End If
End If
End If
Else
FindValue = False
End If
If Err.Number &lt;&gt; 0 Then
FindValue = False
m_ErrorCode = Err.Number
m_ErrorDescription = Err.Description
Err.Clear
End If
On Error Goto 0
End Function

Public Function RegKeyExists(ByVal sHive, ByVal sRegKey)
On Error Resume Next
Call ResetErrors
Dim aValueNames, aValueTypes
RegKeyExists = False
If m_ObjReg.EnumValues(sHive, sRegKey, aValueNames, aValueTypes) = 0 Then
RegKeyExists = True
Else
RegKeyExists = False
End If
If Err.Number &lt;&gt; 0 Then
RegKeyExists = False
m_ErrorCode = Err.Number
m_ErrorDescription = Err.Description
Err.Clear
End If
On Error Goto 0
End Function

Public Function RegValueExists(ByVal sHive, ByVal sRegKey, ByVal sRegValue)
On Error Resume Next
Call ResetErrors
Dim aValueNames, aValueTypes, i
RegValueExists = False
If m_ObjReg.EnumValues(sHive, sRegKey, aValueNames, aValueTypes) = 0 Then
If IsArray(aValueNames) Then
For i = 0 To UBound(aValueNames)
If LCase(aValueNames(i)) = LCase(sRegValue) Then
RegValueExists = True
End If
Next
End If
End If
If Err.Number &lt;&gt; 0 Then
RegValueExists = False
m_ErrorCode = Err.Number
m_ErrorDescription = Err.Description
Err.Clear
End If
On Error Goto 0
End Function


Public Property Get ErrorCode()
ErrorCode = m_ErrorCode
End Property

Public Property Get ErrorDescription()
ErrorDescription = m_ErrorDescription
End Property

Public Default Function Create(ByVal sHostname)
m_Hostname = sHostname
Call ResetErrors
M_HKEY_CLASSES_ROOT = &amp;H80000000
M_HKEY_CURRENT_USER = &amp;H80000001
M_HKEY_LOCAL_MACHINE = &amp;H80000002
M_HKEY_USERS = &amp;H80000003
M_HKEY_CURRENT_CONFIG = &amp;H80000005
M_HKEY_DYN_DATA = &amp;H80000006 ' Windows 95/98 only
M_REG_SZ = 1
M_REG_EXPAND_SZ = 2
M_REG_BINARY = 3
M_REG_DWORD = 4
M_REG_DWORD_BIG_ENDIAN = 5
M_REG_LINK = 6
M_REG_MULTI_SZ = 7
M_REG_RESOURCE_LIST = 8
M_REG_FULL_RESOURCE_DESCRIPTOR = 9
M_REG_RESOURCE_REQUIREMENTS_LIST = 10
M_REG_QWORD = 11
M_REG_KEY_QUERY_VALUE = &amp;H0001
M_REG_KEY_SET_VALUE = &amp;H0002
M_REG_KEY_CREATE_SUB_KEY = &amp;H0004
M_REG_KEY_DELETE = &amp;H00010000
Set m_ObjReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &amp; m_Hostname &amp; "\root\default:StdRegProv")
Set Create = Me
End Function

Private Sub Class_Terminate()
Set m_ObjReg = Nothing
End Sub

End Class

REM Arguments
REM - Action
REM - Arguments
REM - ManagementServer
REM - ManagementGroupName

Sub TasksMain()
Dim err
Dim oArgs
Set oArgs = WScript.Arguments
If oArgs.Count &lt; 1 Then
ErrorExit "Too few arguments!", 1
End If

Dim DM_SERVICE_NAME
DM_SERVICE_NAME = "dmmp_svc"
Dim action, parameters, managementservername, managementgroupname, targetComputer

action = oArgs(0)
If oArgs.Count &gt; 1 Then
parameters = oArgs(1)
If oArgs.Count &gt; 2 Then
managementservername = oArgs(2)
If oArgs.Count &gt; 3 Then
managementgroupname = oArgs(3)
Else
managementgroupname = ""
End If
Else
managementservername = ""
managementgroupname = ""
End If
Else
parameters = ""
managementservername = ""
managementgroupname = ""
End If
targetComputer = oArgs(4)
Dim output, ExitCode
If UCase(action) = "STARTSERVICE" Then
output = "Starting ComTrade MP Agent Service for EMC Documentum ..." &amp; vbNewLine
output = output &amp; StartService(DM_SERVICE_NAME, ExitCode)
If (ExitCode &lt;&gt; 0) Or (InStr(output,"FAILED") &lt;&gt; 0) Then
ErrorExit output, 6
Else
WScript.Echo output
Exit Sub
End If
ElseIf UCase(action) = "STOPSERVICE" Then
output = "Stopping ComTrade MP Agent Service for EMC Documentum ..." &amp; vbNewLine
output = output &amp; StopService(DM_SERVICE_NAME, ExitCode)
If (ExitCode &lt;&gt; 0) Or (InStr(output,"FAILED") &lt;&gt; 0) Then
ErrorExit output, 5
Else
WScript.Echo output
Exit Sub
End If
ElseIf UCase(action) = "SERVICESTATUS" Then
output = "Query Status And Configuration of ComTrade MP Agent Service for EMC Documentum ..." &amp; vbNewLine
output = output &amp; GetServiceStatus(DM_SERVICE_NAME, ExitCode)
If (ExitCode &lt;&gt; 0) Or (InStr(output,"FAILED") &lt;&gt; 0) Then
ErrorExit output, 5
Else
WScript.Echo output
Exit Sub
End If
ElseIf UCase(action) = "SUPPORT" Then
output = "Starting ComTrade MP Support Tool for EMC Documentum ..." &amp; vbNewLine
output = output &amp; StartSupportTool(parameters, managementservername, managementgroupname, ExitCode, targetComputer)
If (ExitCode &lt;&gt; 0) Or (InStr(output,"FAILED") &lt;&gt; 0) Or (InStr(output,"failed") &lt;&gt; 0) Then
ErrorExit output, 5
Else
WScript.Echo output
Exit Sub
End If
ElseIf UCase(action) = "CHECKPREREQ" Then
output = "Starting ComTrade MP Check Prerequisite Tool for EMC Documentum ..." &amp; vbNewLine
output = output &amp; StartSupportTool(parameters, managementservername, managementgroupname, ExitCode, targetComputer)
Dim out1, exCode
out1 = "Documentum MP Action Account [ "
Call CheckActionAccout(exCode, targetComputer)
If exCode = 0 Then
out1 = out1 &amp; " OK ]" &amp; vbNewLine
out1 = out1 &amp; "---------------------------------------------------------------" &amp; vbNewLine
out1 = out1 &amp; "Documentum MP Action Account Resolved" &amp; vbNewLine
Else
out1 = out1 &amp; "Warning ]" &amp; vbNewLine
out1 = out1 &amp; "----------------------------------------------------------------" &amp; vbNewLine
out1 = out1 &amp; "Documentum MP Action Account Not Resolved" &amp; vbNewLine
out1 = out1 &amp; vbNewLine
out1 = out1 &amp; "Please verify that Documentum MP Action Account is set, " &amp; vbNewLine
out1 = out1 &amp; "'Microsoft.SystemCenter.SecureReferenceOverride' is transfered to node" &amp; vbNewLine
out1 = out1 &amp; "and configuration on node is active." &amp; vbNewLine
End If
output = output &amp; out1
If (ExitCode &lt;&gt; 0) Or (InStr(output,"FAILED") &lt;&gt; 0) Or (InStr(output,"failed") &lt;&gt; 0) Or (exCode &lt;&gt; 0) Then
ErrorExit output, 5
Else
WScript.Echo output
Exit Sub
End If
Else
ErrorExit "Task defined by " &amp; Chr(34) &amp; action &amp; Chr(34) &amp; " not implemented yet.", 3
End If
End Sub

Private Function CheckActionAccout(ByRef exitCode, ByVal targetComputer)
Dim oReg, regKy, healthInstallDir, errmsg, output, overrideMp
errmsg = ""
healthInstallDir = ""
Set oReg = New CTRegistry.Create(targetComputer)
If oReg.FindKey(oReg.HKEY_LOCAL_MACHINE,"SOFTWARE\Microsoft\Microsoft Operations Manager", "Setup", regKy) Then
If Not oReg.GetStringValue(oReg.HKEY_LOCAL_MACHINE, regKy, "InstallDirectory", healthInstallDir) Then
If oReg.ErrorCode &lt;&gt; 0 Then
errmsg = "Installation directory of health service not found: " &amp; oReg.ErrorCode &amp; " - " &amp; oReg.ErrorDescription
Else
errmsg = "Installation directory of health service not found."
End If
End If
Else
If oReg.ErrorCode &lt;&gt; 0 Then
errmsg = "Installation of health service not detected: " &amp; oReg.ErrorCode &amp; " - " &amp; oReg.ErrorDescription
Else
errmsg = "Installation of health service not detected."
End If
End If
Set oReg = Nothing
overrideMp = "Microsoft.SystemCenter.SecureReferenceOverride"
If Len(healthInstallDir) &lt; 1 Then
output = "Health service not found." &amp; vbNewLine
If Len(errmsg) &gt; 0 Then
output = output &amp; vbNewLine &amp; "Reason: " &amp; vbNewLine &amp; errmsg
End If
exitCode = 4
CheckActionAccout = output
Exit Function
End If
Dim shellCmd
exitCode = 0
shellCmd = "%comspec% /c type " &amp; Chr(34) &amp; healthInstallDir _
&amp; "\Health Service State\Management Packs\" _
&amp; overrideMp _
&amp; "*.xml" &amp; Chr(34) _
&amp; " | findstr ComTrade.EMC.Documentum.Library.DocumentumActionAccount"
output = ExecuteShellCommand(shellCmd, exitCode)
output = Trim(output)
If exitCode &lt;&gt; 0 Then
output = "Documentum Action Account not resolved"
ElseIf Len(output) &lt; 1 Then
output = "Documentum Action Account not resolved"
exitCode = 1
End If
CheckActionAccout = output
End Function

Sub CreateFolder( ByRef objFSO, ByVal strPath )
On Error Resume Next
If strPath &lt;&gt; "" Then 'Fixes endless recursion in some instances when at lowest directory
If Not objFSO.FolderExists(objFSO.GetParentFolderName(strPath)) Then
Call CreateFolder(objFSO, objFSO.GetParentFolderName(strPath))
End If
objFSO.CreateFolder(strPath )
End If
On Error Goto 0
End Sub

Private Function StartSupportTool(ByVal parameters, ByVal managementservername, ByVal managementgroupname, ByRef ExitCode, ByVal targetComputer)
Dim oReg, regKy, scomserverhostname, errmsg, strCommand, output
errmsg = ""
If Len(managementservername) &gt; 0 Then
scomserverhostname = managementservername
Else
Set oReg = New CTRegistry.Create(targetComputer)
If oReg.FindKey(oReg.HKEY_LOCAL_MACHINE,"SOFTWARE\Microsoft\Microsoft Operations Manager", managementgroupname, regKy) Then
If oReg.FindValue(oReg.HKEY_LOCAL_MACHINE, regKy &amp; "\Parent Health Services", "NetworkName", regKy) Then
If Not oReg.GetStringValue(oReg.HKEY_LOCAL_MACHINE, regKy, "NetworkName", scomserverhostname) Then
If oReg.ErrorCode &lt;&gt; 0 Then
errmsg = oReg.ErrorCode &amp; " - " &amp; oReg.ErrorDescription
Else
errmsg = "Associated NetworkName for Management Group Named " &amp; managementgroupname &amp; " not found."
End If
End If
Else
If oReg.ErrorCode &lt;&gt; 0 Then
errmsg = oReg.ErrorCode &amp; " - " &amp; oReg.ErrorDescription
Else
errmsg = "Associated NetworkName keyname for Management Group Named " &amp; managementgroupname &amp; " in registry not found."
End If
End If
Else
If oReg.ErrorCode &lt;&gt; 0 Then
errmsg = oReg.ErrorCode &amp; " - " &amp; oReg.ErrorDescription
Else
errmsg = "Registry Key for Management Group Name '" &amp; managementgroupname &amp; "' not found."
End If
End If
Set oReg = Nothing
End If
Dim dotNetVersions, dotReqSuccess, regProbeSuccess
dotReqSuccess = False
regProbeSuccess = True
Set oReg = New CTRegistry.Create(targetComputer)
If Not oReg.EnumerateSubKeys(oReg.HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\NET Framework Setup\NDP", dotNetVersions) Then
If Not oReg.EnumerateSubKeys(oReg.HKEY_LOCAL_MACHINE, "SOFTWARE\Wow6432Node\Microsoft\NET Framework Setup\NDP", dotNetVersions) Then
regProbeSuccess = False
End If
End If
If regProbeSuccess Then
If UBound(dotNetVersions) &gt; -1 Then
Dim it
For it = 0 To UBound(dotNetVersions)
If InStr(1, dotNetVersions(it), "v2", 1) &gt; 0 Then
dotReqSuccess = True
Exit For
ElseIf InStr(1, dotNetVersions(it), "v3", 1) &gt; 0 Then
dotReqSuccess = True
Exit For
ElseIf InStr(1, dotNetVersions(it), "v4", 1) &gt; 0 Then
dotReqSuccess = True
Exit For
End If
Next
End If
End If
Set oReg = Nothing
If dotReqSuccess Then
If Len(scomserverhostname) &gt; 0 Then 'manually Set management server name
Dim fso, sFile, curDir
Set fso = CreateObject("Scripting.FileSystemObject")
curDir = "\\" &amp; scomserverhostname &amp; "\ComTradeMP\MP for EMC Documentum"
sFile = "Support.exe"
If (fso.FileExists(curDir &amp; "\" &amp; sFile)) Then
Dim tempFolder, tmpNo, tmpDate
tmpNo = Int(1000*Rnd+1)
tmpDate = Now
tempFolder = fso.GetSpecialFolder(2)
tempFolder = tempFolder &amp; "\ComTrade\" &amp; tmpNo &amp; Year(tmpDate) &amp; Day(tmpDate) &amp; Month(tmpDate) &amp; Hour(tmpDate) &amp; Minute(tmpDate) &amp; Second(tmpDate)
If Not fso.FolderExists(tempFolder) Then
Call CreateFolder(fso, tempFolder)
End If
output = RunCmdUpdate(curDir &amp; "\", sFile, tempFolder, ExitCode)
If InStr(output, "1 ") &gt; 0 Then
strCommand = tempFolder &amp; "\" &amp; sFile &amp; " " &amp; parameters
output = ExecuteShellCommand(strCommand, ExitCode)
WScript.Sleep 1000
fso.DeleteFile tempFolder &amp; "\" &amp; sFile, True
End If
fso.DeleteFolder tempFolder, True
Set fso = Nothing
Else
output = Chr(34) &amp; curDir &amp; sFile &amp; Chr(34) &amp; " does not exist."
ExitCode = 3
End If
Else 'find management server name
output = "Management Server not found. Please Set 'ManagementServer' parameter manually." &amp; vbNewLine
output = output &amp; vbNewLine &amp; "Starting of ComTrade Support Tool failed."
If Len(errmsg) &gt; 0 Then
output = output &amp; vbNewLine &amp; "Automatic detection from Management Group Failed. Reason: " &amp; vbNewLine &amp; errmsg
End If
End If
Else
output = "FAILED: Support tools depend on .NET. Minimum requirements is .NET v2. Please install prerequisites and try again."
End If
StartSupportTool = output
End Function


Sub ErrorExit(ByVal errorMessage, ByVal errorCode)
WScript.StdErr.WriteLine errorMessage
Wscript.Quit errorCode
End Sub

Private Function ExecuteShellCommand(ByVal strShellCommand, ByRef ExitCode)
Dim shell, oexec, strPResult
strPResult = ""
Set shell = CreateObject("WScript.Shell")
Set oexec = shell.exec(strShellCommand)
Do While Not oexec.StdOut.AtEndOfStream
strPResult = strPResult &amp; oexec.StdOut.Read(1024)
Loop
ExitCode = oexec.ExitCode
Set oexec = Nothing
Set shell = Nothing
ExecuteShellCommand = strPResult
End Function

Private Function StopService(ByVal service_name, ByRef ExitCode)
StopService = ExecuteShellCommand("sc.exe stop " &amp; Chr(34) &amp; service_name &amp; Chr(34), ExitCode)
End Function

Private Function RunCmdUpdate(ByVal applicationPath, ByVal appName, ByVal installPath, ByRef ExitCode)
Dim shell, oexec, strPResult
strPResult = ""
Set shell = CreateObject("WScript.Shell")
Set oexec = shell.exec("%comspec% /c copy /Y /V " &amp; Chr(34) &amp; applicationPath &amp; appName &amp; Chr(34) &amp; " " &amp; Chr(34) &amp; installPath &amp; Chr(34))
Do While Not oexec.StdOut.AtEndOfStream
strPResult = strPResult &amp; oexec.StdOut.Read(1024)
Loop
ExitCode = oexec.ExitCode

Set oexec = Nothing
Set shell = Nothing

RunCmdUpdate = strPResult
End Function

Private Function GetServiceStatus(ByVal service_name, ByRef ExitCode)
Dim rtVal
rtVal = "Queries the extended status for a service, or enumerates the status for types of services." &amp; vbNewLine
rtVal = rtVal &amp; ExecuteShellCommand("sc.exe queryex " &amp; Chr(34) &amp; service_name &amp; Chr(34), ExitCode)
rtVal = rtVal &amp; "Queries the configuration information for a service." &amp; vbNewLine
rtVal = rtVal &amp; ExecuteShellCommand("sc.exe qc " &amp; Chr(34) &amp; service_name &amp; Chr(34), ExitCode)
rtVal = rtVal &amp; "Queries the actions taken by a service upon failure." &amp; vbNewLine
rtVal = rtVal &amp; ExecuteShellCommand("sc.exe qfailure " &amp; Chr(34) &amp; service_name &amp; Chr(34), ExitCode)
GetServiceStatus = rtVal
End Function

Private Function StartService(ByVal service_name, ByRef ExitCode)
StartService = ExecuteShellCommand("sc.exe start " &amp; Chr(34) &amp; service_name &amp; Chr(34), ExitCode)
End Function
</Script></Contents>
</File>
</Files>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="executeScript"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.CommandOutput</OutputType>
<InputType>System!System.BaseData</InputType>
</ProbeActionModuleType>