Re: Checking CPU Usage for a Particular Process

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



hi ignignokt,

There may be some obscure performance counter that will give
you what you want, but I have another suggestion.

This will involve calling an api, and if that is distasteful
to you, then you will have to wait around for a better answer.

Still here? Then here's what you do... You "ping" your
(potentially stalled) application. How to "ping" an app?
You send it a message, and see if it responds. Generally,
"SendMessageTimeout" is used, and the suggested message is
"WM_NULL" (a harmless message). Here is a snippet of code,
which is used by the task manager to check if an app
"is awake":

--- <> ---
DWORD dwResult;
BOOL fResponding = SendMessageTimeout(hwndInQuestion,
WM_NULL, 0, 0, SMTO_ABORTIFHUNG, 5000, &dwResult);
// fResponding is TRUE if the thread is responding and
// FALSE if not.
--- <> ---

O.K. so it's c++ code, but it ought to be simple enough
to understand. If the app is "not responding" to the
message you send, then that's a good indication that
it is hung.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)


ignignokt wrote:
I have a vbscript that will call a program and wait til the program is
finished to continue running the script. There are some cases where
the program will get hung and just freeze. I would like to have the
script check the CPU usage of the program after it is called, and if
the CPU usage is 0%, then it will kill the process and the script will
contiune running. Does anyone know how to do this in vbscript?

.



Relevant Pages

  • Re: Creating Secure Standalone Binaries for 9/X
    ... I can't figure out how to lock down the app ... so the IP of the script is unprotected. ... does is copy the text of your script into the resource: ... Of course, as Andreas said, it's probably just a matter that the file type ...
    (comp.lang.tcl)
  • Re: DB Self-destructed!
    ... Probably an excellent suggestion, except that I'd be unable to pay for their ... developer about 30 to 45 minutes to normalize a spreadsheet into a db app ... skills yourself) and how to clean up the data, and let you clean up the ... This morning I just wiped out all earlier tables, kept the original tab ...
    (comp.databases.ms-access)
  • Re: Problem deleting a printer object
    ... I tested out the script suggested by JHP. ... Dim strComputer, objWMI, objPrinter, objWSH, rtnPrinter ... Windows 2000 workstations, Windows XP can handle this without a problem. ... was hoping that someone out there might have a suggestion. ...
    (microsoft.public.scripting.vbscript)
  • Re: Question about a couple PHP scripts
    ... The app itself is running ... will upload GPS data to a URL of your choosing. ...  That script is below. ... posts it along with a google map. ...
    (comp.lang.php)
  • Re: EXAMPLE -- Re: Strange issue with `CHOMP not working...
    ... It is not a "why is my perl 101 assignment script not ... opening but not closing files, and second creating a cache (hash of ... suggestion that I was looking for. ... If my problems reoccur, as they may, I will put that ...
    (comp.lang.perl.misc)