删除深层监视注册表项

Microsoft.JEE.DisableAppServerManagement.RegWriteAction (WriteActionModuleType)

删除深层监视注册表项。

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
InputTypeSystem.BaseData
OutputTypeSystem.BaseData
CommentDisable management of application server

Member Modules:

ID Module Type TypeId RunAs 
UpdateRegistry WriteAction Microsoft.Windows.ScriptWriteAction Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
TargetInstanceIdstring$Config/TargetInstanceId$目标实例 ID目标实例的 GUID。
TaskTimeoutSecondsstring$Config/TaskTimeoutSeconds$超时数据源无活动的超时值(以秒为单位)。

Source Code:

<WriteActionModuleType ID="Microsoft.JEE.DisableAppServerManagement.RegWriteAction" Comment="Disable management of application server" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element name="ManagementGroupId" type="xsd:string"/>
<xsd:element name="TargetInstanceId" type="xsd:string"/>
<xsd:element name="TaskTimeoutSeconds" type="xsd:int"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="TargetInstanceId" Selector="$Config/TargetInstanceId$" ParameterType="string"/>
<OverrideableParameter ID="TaskTimeoutSeconds" Selector="$Config/TaskTimeoutSeconds$" ParameterType="string"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<WriteAction ID="UpdateRegistry" TypeID="Windows!Microsoft.Windows.ScriptWriteAction">
<ScriptName>JEEAppServerDisableManagement.vbs</ScriptName>
<Arguments>$Config/ManagementGroupId$ "$Config/TargetInstanceId$"</Arguments>
<ScriptBody><Script>
''' Copyright (c) Microsoft Corporation. All rights reserved.
''' Date Created: Oct 8th, 2010
'
SetLocale("en-us")
'''
''' Constants for Registry Access
'''
CONST HKEY_LOCAL_MACHINE = &amp;H80000002
CONST REGISTRY_PROP_ID = "ID"
CONST REGISTRY_PROP_PROTOCOL = "PROTOCOL"
CONST MONITORED_REGISTRY_KEY = "MonitoredJEEAppServers"
'''
''' Simple Class defining a combination of protocol and port
'''
CLASS ProtocolAndPort
PUBLIC Protocol
PUBLIC Port
END CLASS
'
' Check the registry and see if an entry have been created for the provided application server Id
'
FUNCTION AppServerEnabledForDeepManagement(userSuppliedMOMAPI, userSuppliedRegistry, groupId, appServerId, foundKey, foundProtocol)
IF userSuppliedRegistry Is Nothing THEN
SET objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
ELSE
SET objRegistry = userSuppliedRegistry
END IF
IF userSuppliedMOMAPI Is Nothing THEN
SET oApi = CreateObject("MOM.ScriptAPI")
ELSE
SET oApi = userSuppliedMOMAPI
END IF
GetBaseRegistryPath = oAPI.GetScriptStateKeyPath(groupId)
ManagedJEEAppServersPath = GetBaseRegistryPath &amp; "\" &amp; MONITORED_REGISTRY_KEY
AppServerEnabledForDeepManagement = false
objRegistry.EnumKey HKEY_LOCAL_MACHINE, ManagedJEEAppServersPath, arrSubKeys
IF NOT IsNull(arrSubKeys) THEN
DIM subKey
FOR EACH subKey In arrSubKeys
DIM fullSubKey
fullSubKey = ManagedJEEAppServersPath &amp; "\" &amp; subKey
objRegistry.GetStringValue HKEY_LOCAL_MACHINE, fullSubKey, REGISTRY_PROP_ID, SavedAppServerId
IF SavedAppServerId = appServerId THEN
AppServerEnabledForDeepManagement = true
foundKey = fullSubKey
objRegistry.GetStringValue HKEY_LOCAL_MACHINE, fullSubKey, REGISTRY_PROP_PROTOCOL, SavedProtocol
foundProtocol = SavedProtocol
END IF
NEXT
END IF
END FUNCTION
'
' Check if a given URL returns a valid response
'
FUNCTION URLCheck(objSvrHTTP, URL, username, password)
URLCheck = false
if objSvrHTTP is nothing then
Set objSvrHTTP = CreateObject("Microsoft.XmlHttp")
end if
ON ERROR RESUME NEXT
objSvrHTTP.open "GET", URL, false, username, password
IF Err.Number = 0 THEN
objSvrHTTP.send
IF Err.Number = 0 THEN
IF objSvrHTTP.status = 200 THEN
URLCheck = true
END IF
END IF
END IF
END FUNCTION
'
' Check if a we should use HTTPS or HTTP to communicate with BeanSpy
'
FUNCTION GetProtocolAndPort(objSvrHTTP, principalName, httpPort, httpsPort, userName, password)
SET result = NEW ProtocolAndPort
result.Protocol = "HTTPS"
result.Port = httpsPort
httpsok = false
IF httpsPort &lt;&gt; "" AND httpsPort &lt;&gt; "0" THEN
url = "https://" &amp; principalName &amp; ":" &amp; httpsPort &amp; "/BeanSpy/Stats"
httpsok = URLCheck(objSvrHTTP, url, userName, password)
END IF
IF httpsok = false THEN
httpok = false
IF httpPort &lt;&gt; "" AND httpPort &lt;&gt; "0" THEN
url = "http://" &amp; principalName &amp; ":" &amp; httpPort &amp; "/BeanSpy/Stats"
httpok = URLCheck(objSvrHTTP, url, userName, password)
END IF
IF httpok = true OR httpsPort = "" OR httpsPort = "0" THEN
result.Protocol = "HTTP"
result.Port = httpPort
END IF
END IF
SET GetProtocolAndPort = result
END FUNCTION

''' Copyright (c) Microsoft Corporation. All rights reserved.
''' Date Created: Oct 8th, 2010
'
SetLocale("en-us")
'
' Check the registry and see if an entry have been created for the provided application server Id
' if it has, delete it from the registry
'
FUNCTION DisableDeepManagement(userSuppliedMOMAPI, userSuppliedRegistry, groupId, appServerId)
IF userSuppliedRegistry Is Nothing THEN
SET objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
ELSE
SET objRegistry = userSuppliedRegistry
END IF
enabled = AppServerEnabledForDeepManagement(userSuppliedMOMAPI, objRegistry, groupId, appServerId, foundKey, foundProtocol)
IF enabled = true THEN
objRegistry.DeleteKey HKEY_LOCAL_MACHINE, foundKey
END IF
END FUNCTION

Set oArgs = WScript.Arguments
if oArgs.Count &lt; 2 Then
Wscript.Quit -1
End If

DisableDeepManagement Nothing, Nothing, oArgs(0), oArgs(1)
</Script></ScriptBody>
<TimeoutSeconds>$Config/TaskTimeoutSeconds$</TimeoutSeconds>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="UpdateRegistry"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.BaseData</OutputType>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>