Stop Component

Microsoft.FASTSearch.MP.Task.NCtrlComponent.Stop (Task)

This task stops the component using the nctrl.exe tool.

Element properties:

TargetMicrosoft.FASTSearch.MP.Entity.NCtrlComponent
AccessibilityPublic
CategoryCustom
EnabledTrue
RemotableFalse
Timeout500

Member Modules:

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

Source Code:

<Task ID="Microsoft.FASTSearch.MP.Task.NCtrlComponent.Stop" Accessibility="Public" Enabled="true" Target="Microsoft.FASTSearch.MP.Entity.NCtrlComponent" Timeout="500" Remotable="false">
<Category>Custom</Category>
<WriteAction ID="PA" TypeID="Windows!Microsoft.Windows.ScriptWriteAction">
<ScriptName>NCtrlComponentStop.vbs</ScriptName>
<Arguments>stop $Target/Property[Type="Microsoft.FASTSearch.MP.Entity.NCtrlComponent"]/Id$</Arguments>
<ScriptBody><Script>Option Explicit
On Error Resume Next

SetLocale("en-us")

' NOTE: SCOM parsing of stderr output is strange, so send all to stdout

Const FastRegValue = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\FAST Search Server\Setup\Path"
Const FastEnvVar = "FASTSEARCH"


if WScript.Arguments.Count &lt; 2 Then
WScript.StdOut.WriteLine "Insufficient number of arguments provided to script."
WScript.Quit 0
End If

Dim strCommand
strCommand = WScript.Arguments(0)

Dim strProcId
strProcId = WScript.Arguments(1)

Dim WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")


Dim oEnv
Set oEnv = WSHShell.Environment("Process")

Dim strPath
strPath = oEnv(FastEnvVar)
If strPath = "" Then
WScript.StdOut.WriteLine FastEnvVar &amp; " environment variable not found. Reading from registry."

strPath = WSHShell.RegRead(FastRegValue)

If Err.Number &lt;&gt; 0 Then
WScript.StdOut.WriteLine "Registry key not found:" &amp; vbCRLF &amp; FastRegValue
WScript.Quit 0
End If

oEnv(FastEnvVar) = strPath
End If


If Right(strPath, 1) &lt;&gt; "\" Then ' Add trailing slash if required
strPath = strPath &amp; "\"
End If

Dim strNCtrlPath
strNCtrlPath = """" &amp; strPath &amp; "bin\nctrl.exe"""

Dim strCmdLine
strCmdline = strNCtrlPath &amp; " " &amp; strCommand &amp; " " &amp; strProcId

Dim oExec
Set oExec = WSHShell.Exec(strCmdLine)

If Err.Number &lt;&gt; 0 Then
WScript.StdOut.WriteLine "Unable to run " &amp; strCmdLine &amp; vbCrlf &amp; Err.Description
WScript.Quit 0
End If


With oExec
Do While .Status = 0
WScript.Sleep 100

Do While Not .StdOut.AtEndOfStream
WScript.StdOut.Write(.StdOut.Read(1))
Loop

Do While Not .StdErr.AtEndOfStream
WScript.StdOut.Write(.StdErr.Read(1))
Loop
Loop
End With

WScript.StdOut.WriteLine " " ' Always provide _some_ stdout data
WScript.Quit 0
</Script></ScriptBody>
<TimeoutSeconds>400</TimeoutSeconds>
</WriteAction>
</Task>