Uninstall Documentum MP Agent on Node

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

Removes documentum management agent from node.

Element properties:

TypeProbeActionModuleType
IsolationAny
AccessibilityPublic
RunAsDefault
InputTypeSystem.BaseData
OutputTypeSystem.CommandOutput

Member Modules:

ID Module Type TypeId RunAs 
executeScript ProbeAction System.CommandExecuterProbe Default

Source Code:

<ProbeActionModuleType ID="ComTrade.EMC.Documentum.Windows.PA.MPAgent.Uninstall" Accessibility="Public" Batching="true" PassThrough="false">
<Configuration/>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="executeScript" TypeID="System!System.CommandExecuterProbe">
<ApplicationName>%windir%\system32\cscript.exe</ApplicationName>
<WorkingDirectory/>
<CommandLine>//NoLogo $File/CTDmMPDocumentumAgentUninstallationDataProv.vbs$</CommandLine>
<TimeoutSeconds>900</TimeoutSeconds>
<RequireOutput>true</RequireOutput>
<Files>
<File>
<Name>CTDmMPDocumentumAgentUninstallationDataProv.vbs</Name>
<Contents><Script>Option Explicit
SetLocale("en-us")
Call UninstallMain()

Sub UninstallMain()
Dim inst_uninst, inst_str, output, ExitCode, ProductCode
inst_str = "Uninstallation "
inst_uninst = "msiexec.exe /quiet /x"
ProductCode = "{DB45895B-C92C-44EB-96C9-8C00DEC468DE}"
output = ""
output = output &amp; "Executing command: " &amp; Chr(34) &amp; inst_uninst &amp; " " &amp; ProductCode &amp; Chr(34) &amp; vbNewLine
output = output &amp; RunCmd(inst_uninst, "", "", ProductCode, ExitCode) &amp; vbNewLine

If ExitCode &lt;&gt; 0 Then
output = output &amp; vbNewLine &amp; inst_str &amp; "failed."
ErrorExit output, ExitCode
Else
output = output &amp; vbNewLine &amp; inst_str &amp; "completed successfully." &amp; vbNewLine
End If
If (InStr(output, "FAILED") &lt;&gt; 0) Or (InStr(output, "Error") &lt;&gt; 0) Or (InStr(output, "The system cannot find the file specified") &lt;&gt; 0) Or (InStr(output, "The network path was not found") &lt;&gt; 0) Then
ErrorExit output, 2
Else
WScript.Echo output
End If
End Sub

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

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 RunCmd(ByVal inst_uninst, ByVal curDir, ByVal sFile, ByVal params, ByRef errorCode)
Dim shell, oexec, fso, strPResult, cmdLine
strPResult = ""
cmdLine = "%comspec% /c " &amp; inst_uninst &amp; Chr(34) &amp; curDir &amp; sFile &amp; Chr(34) &amp; params
Set fso = CreateObject("Scripting.FileSystemObject")
If (Len(sFile) = 0 Or fso.FileExists(curDir &amp; sFile)) Then
Set shell = CreateObject("WScript.Shell")
If Len(curDir) &gt; 0 Or Len(sFile) &gt; 0 Then
Set oexec = shell.exec("%comspec% /c " &amp; inst_uninst &amp; Chr(34) &amp; curDir &amp; sFile &amp; Chr(34) &amp; params)
Else
Set oexec = shell.exec("%comspec% /c " &amp; inst_uninst &amp; " " &amp; params)
End If
oexec.stdin.close()
'wait until process ends
Dim iCnt, timeouted
iCnt = 600
timeouted = False
Do While oexec.Status = 0
WScript.Sleep 50
iCnt = iCnt - 1 'timeout
If 0 &gt; iCnt Then
timeouted = True
Exit Do
End If
Loop

Do While Not oexec.StdOut.AtEndOfStream
'strPResult = strPResult &amp; oexec.StdOut.ReadLine() &amp; vbNewLine
strPResult = oexec.StdOut.ReadAll()
strPResult = unescape(replace(escape(strPResult),"%00","")) 'convert unicode to ascii
Loop

If timeouted = False Then
errorCode = oexec.ExitCode
Else
errorCode = getErrorCodeFromOutput(strPResult)
End If
Else
strPResult = "File does not exist."
errorCode = 1
End If
Set fso = Nothing
RunCmd = strPResult
End Function

Private Function RunCheckPrereqCmd(ByVal curDir, ByVal sFile, ByVal parameters, ByRef errorCode)
Dim shell, oexec, fso, strPResult
strPResult = ""
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(curDir &amp; sFile)) Then
Set shell = CreateObject("WScript.Shell")
shell.currentdirectory = curDir
Set oexec = shell.exec("%comspec% /c " &amp; Chr(34) &amp; curDir &amp; sFile &amp; Chr(34) &amp; " " &amp; parameters)

oexec.stdin.close()
'wait until process ends
Dim iCnt, timeouted
iCnt = 600
timeouted = False
Do While oexec.Status = 0
WScript.Sleep 50
iCnt = iCnt - 1 'timeout
If 0 &gt; iCnt Then
timeouted = True
Exit Do
End If
Loop

Do While Not oexec.StdOut.AtEndOfStream
strPResult = oexec.StdOut.ReadAll()
Loop

If timeouted = False Then
errorCode = oexec.ExitCode
Else
errorCode = getErrorCodeFromOutput(strPResult)
End If
Else
strPResult = Chr(34) &amp; curDir &amp; sFile &amp; Chr(34) &amp; " does not exist."
errorCode = 1
End If

Set oexec = Nothing
Set shell = Nothing

RunCheckPrereqCmd = strPResult
End Function

Private Function getErrorCodeFromOutput(ByVal strPResult)
Dim CHECK_OK, CHECK_FAILED, CHECK_WARNING, pos
CHECK_OK = "[ OK ]"
CHECK_WARNING = "[ Warning ]"
CHECK_FAILED = "[ Failed ]"
getErrorCodeFromOutput = 0

pos = InStr(strPResult, CHECK_WARNING)
If pos &gt; 0 Then
getErrorCodeFromOutput = 1
End If

pos = InStr(strPResult, CHECK_FAILED)
If pos &gt; 0 Then
getErrorCodeFromOutput = 2
End If

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>