The below code kills the javaw.exe process less than 40k size
Public sub close_processes
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process where name = 'javaw.exe'")
npr=colProcess.count
ReDim arrOld(npr)
i=0
For Each objProcess in colProcess
If (objProcess.WorkingSetSize/1000000)<40 Then
arrOld(i)=objProcess.ProcessId
i=i+1
End If
Next
For i=0 to ubound(arrOld)-1
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process where processID='" & arrOld(i) & "'")
For Each objWMIProcess In colProcess
intRC = objWMIProcess.Terminate()
Next
Next
Set objWMIService = Nothing
Set colProcess = Nothing
End Sub
Public sub close_processes
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process where name = 'javaw.exe'")
npr=colProcess.count
ReDim arrOld(npr)
i=0
For Each objProcess in colProcess
If (objProcess.WorkingSetSize/1000000)<40 Then
arrOld(i)=objProcess.ProcessId
i=i+1
End If
Next
For i=0 to ubound(arrOld)-1
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process where processID='" & arrOld(i) & "'")
For Each objWMIProcess In colProcess
intRC = objWMIProcess.Terminate()
Next
Next
Set objWMIService = Nothing
Set colProcess = Nothing
End Sub