Page tree

You can run an external program to check a process from within your rule by editing the code.
The System.Diagnostics.Process class allows you to do this.

 

' Create a process to run the DOS command in
Dim oProcess As New System.Diagnostics.Process

' Fill in the DOS command details
oProcess.StartInfo.FileName = sExeName
oProcess.StartInfo.Arguments = sArguments
oProcess.StartInfo.UseShellExecute = False
oProcess.StartInfo.CreateNoWindow = True
oProcess.StartInfo.RedirectStandardOutput = True

' Run the DOS command
oProcess.Start()

' Set a timer and, if the process doesn't complete in time, kill it
Dim bSuccess As Boolean = oProcess.WaitForExit(1000 * iTimeoutSeconds)

' If the process completed in time
If bSuccess Then
' Create a StreamReader to read the output from the DOS command
Dim oOutputStream As System.IO.StreamReader = oProcess.StandardOutput

' Create a simple string to hold the output from the DOS command
Dim sOutput As String = oOutputStream.ReadToEnd()

' Create an integer to hold the exit code from the DOS command
Dim iExit As Integer = oProcess.ExitCode

< … Do something with the results … >

End If

  • No labels