if WScript.Arguments.Count < 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 & " environment variable not found. Reading from registry."
strPath = WSHShell.RegRead(FastRegValue)
If Err.Number <> 0 Then
WScript.StdOut.WriteLine "Registry key not found:" & vbCRLF & FastRegValue
WScript.Quit 0
End If
oEnv(FastEnvVar) = strPath
End If
If Right(strPath, 1) <> "\" Then ' Add trailing slash if required
strPath = strPath & "\"
End If
Dim strNCtrlPath
strNCtrlPath = """" & strPath & "bin\nctrl.exe"""
Dim strCmdLine
strCmdline = strNCtrlPath & " " & strCommand & " " & strProcId
Dim oExec
Set oExec = WSHShell.Exec(strCmdLine)
If Err.Number <> 0 Then
WScript.StdOut.WriteLine "Unable to run " & strCmdLine & vbCrlf & 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>