VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



WMI sample: checks if a process is running on a (remote) computer. Uses win32_process WMI class.

by Anonymous (267 Submissions)
Category: Windows System Services
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sun 4th May 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

WMI sample: checks if a process is running on a (remote) computer. Uses win32_process WMI class.

Rate WMI sample: checks if a process is running on a (remote) computer. Uses win32_process WMI class.



' This function checks if a process is running on a (remote) computer
' Requires WMI

' Check out http://www.activexperts.com for more samples and components


Function IsProcessRunning( strServer, strProcess )
    Dim Process, strObject
    IsProcessRunning = False
    strObject   = "winmgmts://" & strServer
    For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
If UCase( Process.name ) = UCase( strProcess ) Then
            IsProcessRunning = True
            Exit Function
        End If
    Next
End Function


' Main

Dim strComputer, strProcess
Do
   strProcess = inputbox( "Please enter the name of the process (for instance: explorer.exe)", "Input" )
Loop until strProcess <> ""
Do
   strComputer = inputbox( "Please enter the computer name", "Input" )
Loop until strComputer <> ""
If( IsProcessRunning( strComputer, strProcess ) = True ) Then
    WScript.Echo "Process " & strProcess & " is running on computer " & strComputer
Else
    WScript.Echo "Process " & strProcess & " is NOT running on computer " & strComputer
End If

Download this snippet    Add to My Saved Code

WMI sample: checks if a process is running on a (remote) computer. Uses win32_process WMI class. Comments

No comments have been posted about WMI sample: checks if a process is running on a (remote) computer. Uses win32_process WMI class.. Why not be the first to post a comment about WMI sample: checks if a process is running on a (remote) computer. Uses win32_process WMI class..

Post your comment

Subject:
Message:
0/1000 characters