soubalaji has asked for the wisdom of the Perl Monks concerning the following question:

Is there any way to check whether the exe file is running or not in the server.

Replies are listed 'Best First'.
Re: Check the exe is running or not
by Anonymous Monk on Oct 24, 2008 at 06:17 UTC

      Also, DBD::WMI, if WMI is enabled on the server. Alternatively Net::SSH or GRID for remote execution of one of the other solutions.

Re: Check the exe is running or not
by ikegami (Patriarch) on Oct 24, 2008 at 06:33 UTC
    If you're trying to prevent two copies of your program from running, you can try to get a global resource such as a lock on a specific file or on a specific named mutex, etc.
Re: Check the exe is running or not
by cdarke (Prior) on Oct 24, 2008 at 15:09 UTC
    One reason for wanting that is when replacing an exe file in an upgrade system - on Windows an exe becomes part of the paging system when running and cannot be replaced.

    A problem though is that you can get a race condition: you check that no one is running the exe, then someone does run it milliseconds after you checked.

    One neat trick you can do is to rename the exe file, even though it is running (myprog.exe.old, for example). Then you don't necessarily care if it was running, the new one will be picked up later.

    Be careful when replacing DLLs though, programs can pick these up on the fly and if they get some from the old version and some from the new then all hell breaks loose.