Windows process status using a VB 6.0 Program

Posted on 2005-04-12
Last Modified: 2007-12-19
Dear Experts,

How to find out whether a process is running or exited on windows using a visual basic 6.0 program.

if i give the exe name , want to find out whether it is running
or not ?

Please help me

Thanks and Regards,
Question by:btprabhu
    LVL 7

    Accepted Solution

    Private Sub Form_Load()

    Dim strComputer, strProcess
       strProcess = InputBox("Please enter the name of the process (for instance: explorer.exe)", "Input")
    Loop Until strProcess <> ""
       strComputer = InputBox("Please enter the computer name", "Input")
    Loop Until strComputer <> ""
    If (IsProcessRunning(strComputer, strProcess) = True) Then
        Debug.Print "Process " & strProcess & " is running on computer " & strComputer
        Debug.Print "Process " & strProcess & " is NOT running on computer " & strComputer
    End If
    End Sub

    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
    End Function

    just use localhost for the server and it should work fine.
    LVL 26

    Assisted Solution

    may be just

    dim strProcess, colProcessList, objProcess

    strProcess = "notepad.exe"

    Set colProcessList = GetObject("Winmgmts:").ExecQuery ("Select * from Win32_Process Where Name ='" & strProcess & "'")

    For Each objProcess in colProcessList

    Set colProcessList = Nothing

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    Suggested Solutions

    There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now