+ Reply to Thread
Results 1 to 2 of 2

VBA Code to Monitor if a Program is Running

Hybrid View

rjj920 VBA Code to Monitor if a... 01-30-2021, 08:20 PM
rjj920 Re: VBA Code to Monitor if a... 01-30-2021, 08:42 PM
  1. #1
    Forum Contributor
    Join Date
    12-09-2015
    Location
    Virginia, USA
    MS-Off Ver
    Excel 365
    Posts
    129

    VBA Code to Monitor if a Program is Running

    I have a custom program that was built in python (lets call it RJTV.exe) that can be a little buggy. It runs in the background parsing csv's, but on occasion it will just crash or stop running for no apparent reason.

    I am looking for a program or running a VBA macro that can monitor if this program is running. If it stops, I'd like for it to alert me or create a log at least of when the program stopped. Bonus points if the log can print what time the program started and what time the program crashed.

    I assume I'd have to tap into the task manager, but I'm not sure how I would go about doing this.

    Thanks!

  2. #2
    Forum Contributor
    Join Date
    12-09-2015
    Location
    Virginia, USA
    MS-Off Ver
    Excel 365
    Posts
    129

    Re: VBA Code to Monitor if a Program is Running

    Sub exampleIsProcessRunning()
        Debug.Print IsProcessRunning("RJTV.EXE")
    
    End Sub
    Function IsProcessRunning(process As String)
        Dim objList As Object
    
        Set objList = GetObject("winmgmts:") _
            .ExecQuery("select * from win32_process where name='" & process & "'")
    
        If objList.Count > 0 Then
            IsProcessRunning = True
        Else
            IsProcessRunning = False
        End If
    
    End Function
    This code kind of works, but I'd like for it to continuously loop (without catching my computer on fire from all the iterations) and give a time stamp for when it crashes.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 10-17-2017, 10:36 PM
  2. Replies: 7
    Last Post: 01-17-2017, 06:26 PM
  3. A problem when running program code residing in another workbook
    By eMKaa in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-17-2016, 06:41 AM
  4. [SOLVED] Excel Hangs when running Macro unless resource monitor open on top of excel??????
    By JimBobBowie in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-16-2014, 10:55 AM
  5. Monitor which macro is running??
    By james 35 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-21-2013, 12:27 PM
  6. program error and adding monitor serial number
    By mhelpdesk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-25-2011, 10:36 AM
  7. VBA Delete Code not running in full program
    By WasWodge in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-04-2010, 12:04 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1