+ Reply to Thread
Results 1 to 11 of 11

Determining if a process is not responding using vba

  1. #1
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Determining if a process is not responding using vba

    Hello,

    Quick background... I have a windows-based program that frequently hangs. Normally, I have to manually terminate and restart the program. I have created a subroutine that does this automatically using the Windows API, but I can't get the trigger (program not responding) part to work. It should be something like this (modified from vb posts on the net):

    Please Login or Register  to view this content.
    Any advice is highly welcomed.

    Thank you.

    abousetta

    P.S. In case anyone is interested, here is the code to close then open the program.

    Please Login or Register  to view this content.
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Determining if a process is not responding using vba

    that first routine looks like vb.net code to me-is it?

    also do you require 64bit compatibility as implied by the second set of code?
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Determining if a process is not responding using vba

    Hi JosephP,

    I believe it is vb.net, and I have been unable to amend the code. The process is running as 32 bit (I believe) as in the Task Manager it is presented as EndNote.exe *32.

    I just found code in vba that uses windows management to identify the processes that are currently running. Using it I can isolate the program but I can't find out if it is 'responding' or not.

    Please Login or Register  to view this content.
    Hope you are more familiar with these methods than I am.

    Thanks again for your insight.

    abousetta
    Last edited by abousetta; 03-11-2013 at 05:43 AM. Reason: Slight modification to the Query

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Determining if a process is not responding using vba

    what I was asking is if you need it to be 64bit compatible?

    the wmi process data doesn't seem to be much use for this-the executionstate property just returns null for me no matter what. it may be possible to use the threadstate information from the process' threads but I'm not sure-I will do some experimenting. it may also be possible to use additional api calls so I will look into that

  5. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Determining if a process is not responding using vba

    Hi,

    Why not just write your application in .Net? I've written 90% of the above for you in C#, seems like a trivial task to adapt the vb code you have to include into your project?

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Determining if a process is not responding using vba

    I don't currently have a hanging process to test but perhaps this will help-requires a window handle which you seem to have
    Please Login or Register  to view this content.

  7. #7
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Determining if a process is not responding using vba

    Thanks JP. I've modified my code above to use the FindWindowLike and WindowText APIs to get the handle and pass it to SendMessageTimeout. My only remaining problem is that regardless of the time I put, it initiates the WM_CLOSE. Do you know what I'm doing wrong?

    Please Login or Register  to view this content.
    Thanks.

    abousetta

  8. #8
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Determining if a process is not responding using vba

    I should also that yes, I am trying to make it compatible with both 32 and 64-bit systems that I run these programs on different setups at work and at home.

    Thanks again.

    abousetta

  9. #9
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Determining if a process is not responding using vba

    I don't think you are doing anything wrong-I misunderstood the purpose

    I will try and find an alternative

  10. #10
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Determining if a process is not responding using vba

    perhaps add
    Please Login or Register  to view this content.
    and send WM_NULL instead of WM_CLOSE in the SMTO call?

  11. #11
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Determining if a process is not responding using vba

    Thanks JP. With a few modifications I got it work. It seems that WM_CLOSE does not terminate the process but rather attempts to close the program more or so naturally. Therefore with no hangups it works fine, but when the hang happens it stops waiting for the program to respond. Therefore I just used a different code using windows management to kill the process if this happens.

    Here is my final code:

    Please Login or Register  to view this content.
    Have a great day.

    abousetta
    Last edited by abousetta; 03-11-2013 at 10:27 AM. Reason: Updated code

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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