### Check Java Process running

This example Non-UI Application checks if Java is running.
Note
Check for Mac Operating System not defined as author has noMac.
'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region
`Sub Process_Globals
Private shl As Shell
End Sub`
`Sub AppStart (Args() As String)
Dim params As List: params.Initialize
'Check os first
Dim os As String = GetSystemProperty("os.name", "").ToLowerCase
Log("Operating System: " & os)
'Windows
If os.Contains("win") Then
params.Add("/v")
params.Add("/FI")
params.Add("""IMAGENAME eq java.exe""")
shl.Initialize("shl", "tasklist", params)
Try
Log("Running Shell for Windows")
shl.Run(-1)
Catch
Log(LastException.Message)
End Try
'Mac
Else If os.Contains("mac") Then
'NOT DEFINED
'TO BE ADDED - is like Linux but author can not test as no Mac.
Else
'Linux
params.Add("aux")
params.Add("|")
params.Add("grep")
params.Add("java")
shl.Initialize("shl", "ps", params)
Try
Log("Running Shell for Linux")
shl.Run(-1)
Catch
Log(LastException.Message)
End Try
End If
Log("Waiting for Shell to complete")
StartMessageLoop
End Sub`
`Sub shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
' Log("Shell Completed. Success: " & Success & ", ExitCode:" & ExitCode)
Dim strResult As String
If Success And ExitCode = 0 Then
strResult = "Shell process completed successfully."& CRLF & "Result:" & CRLF & StdOut
Else
strResult = "Shell process NOT completed."& CRLF & "Error: " & CRLF & StdErr
End If
Log(strResult)
ExitApplication
End Sub`

Changed: , Category: Shell, File: T6C248M1787.htm, ID: 1787