VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Network Monitoring task: check if process is running. ActiveXperts Network Monitor has lots of VBSc

by Anonymous (267 Submissions)
Category: Registry
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 31st July 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Network Monitoring task: check if process is running. ActiveXperts Network Monitor has lots of VBScript functions available to check various

Rate Network Monitoring task: check if process is running. ActiveXperts Network Monitor has lots of VBSc



' This function checks if the process, specified by strProcess, is running on 
' the machine specified by strComputer. It only works for Windows 2000 or higher.

On Error Resume Next

    Dim objWmi, objProcess, collProcesses
    Dim strQuery

    set objWmi = GetObject("winmgmts://" & strComputer )
    If( Err.Number <> 0 ) Then
        CheckProcess = retvalUnknown
EXPLANATION = "Unable to access '" & strComputer & "'. Possible reasons: no WMI installed on the remote server, no rights to access remote WMI service, or remote server down"
        Exit Function 
    End If

    strQuery = "select * from win32_process"
    set collProcesses = objWmi.ExecQuery( strQuery ) 
    If( collProcesses.Count = 0 ) Then
        CheckProcess = retvalUnknown
        EXPLANATION = "Unable to list processes on computer '" & strComputer & "'"
        Exit Function     
    End If

    For Each objProcess in collProcesses
        If( Err.Number <> 0 ) Then
            CheckProcess = retvalUnknown
            EXPLANATION = "Unable to list processes on computer '" & strComputer & "'"
            Exit Function 
        End If
If UCase( objProcess.Name ) = UCase( strProcess ) Then
            CheckProcess = True
         EXPLANATION = "Process '" & strProcess & "' is running on computer '" & strComputer & "'"
            Exit Function
        End If
    Next

    CheckProcess = False
    EXPLANATION = "Process '" & strProcess & "' is not running on computer '" & strComputer & "'"

End Function

Download this snippet    Add to My Saved Code

Network Monitoring task: check if process is running. ActiveXperts Network Monitor has lots of VBSc Comments

No comments have been posted about Network Monitoring task: check if process is running. ActiveXperts Network Monitor has lots of VBSc. Why not be the first to post a comment about Network Monitoring task: check if process is running. ActiveXperts Network Monitor has lots of VBSc.

Post your comment

Subject:
Message:
0/1000 characters