My Fellow Monks,
(I know you will feel my pain)

Woe is me, for I have been tasked with using Perl to ensure another Perl program is running on a win2K machine. I offered to forego my internet privileges for a month if they would let the cup pass, but the Powers-That-Be declined :-)

Here is my situation:
I have a little script that launches on Windows startup. All it does is tail an application log every 5 minutes and then send an email to a particular user if certain messages appear in the log. Very plain, very simple. When I check the Windows machine, I discover that, for some reason, the script is no longer running. I have an error logging facility for it, but nothing in it indicates why it has died. The application whose log it is tailing is still running and everyone who has access to the machine swears they are not killing it. So I have been asked to write something that will check periodically to see if the script has died, and if so, kick it off again. (The Powers-That-Be were not interested in hearing about what would need to be done if the script that checks the script dies also).

So, finally, to my question:
Do any of you know of a way to get a list of all running programs on a Windows machine either my name or process Id? I figure this is the best way to determine if a program is running. I have examined the Win32 modules, but I cannot find anything. If it's in there, I certainly am missing it.
Or, if any of you have any other suggestions for how I might accomplish this task, I am most definately all ears.

as always, your input is greatly appreciated.
davidj

In reply to Check if a process is running on Windows by davidj

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.