Shoutbox

HELP REQUEST check if an exe is running - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: HELP REQUEST check if an exe is running (/showthread.php?tid=75433)

HELP REQUEST check if an exe is running by lovefallen on 06-17-2007 at 07:34 PM

Hello everyone,
basically  i want to do make a script that checks if wmp is running or not, then stop another script from working.. i'm new to scripting though not to programming.. I've read official documentation and msdn jscript documentation, but still I can't understand how exactly scripts work.. any help is much appreciated! :)


RE: HELP REQUEST check if an exe is running by matty on 06-18-2007 at 02:08 PM

You can use the EnumProcesses API to do this. I will try and post an example today for you.


RE: HELP REQUEST check if an exe is running by Voldemort on 06-18-2007 at 03:45 PM

quote:
Originally posted by lovefallen
then stop another script from working.
I am no scripter so i may be newbing, but afaik you can't stop a script from another script....
RE: HELP REQUEST check if an exe is running by deAd on 06-18-2007 at 04:21 PM

quote:
Originally posted by lovefallen
basically  i want to do make a script that checks if wmp is running or not, then stop another script from working..
You can't stop scripts from running using a script. You'd need to implement this directly into the other WMP script.

quote:
Originally posted by Matty
You can use the EnumProcesses API to do this. I will try and post an example today for you.
Another way which is simpler but less reliable is to find a uniquely named/classed, always-present window from that process and check if it exists.
RE: HELP REQUEST check if an exe is running by matty on 06-18-2007 at 04:21 PM

quote:
Originally posted by Voldemort
quote:
Originally posted by lovefallen
then stop another script from working.
I am no scripter so i may be newbing, but afaik you can't stop a script from another script....
Haha sure you can.

HKEY_CURRENT_USER\Software\Patchou\Messenger Plus! Live\GlobalSettings\Scripts\Screenshot Sender 4

Change Enabled to 0. Then use either FSO or API to read and resave the file (or modify the date and time). It will call the script to restart but because it is Disabled it wont run.
RE: RE: HELP REQUEST check if an exe is running by deAd on 06-18-2007 at 04:40 PM

quote:
Originally posted by Matty
Change Enabled to 0. Then use either FSO or API to read and resave the file (or modify the date and time). It will call the script to restart but because it is Disabled it wont run.

That won't always work, because reloading scripts is only enabled in Debug mode (I may be wrong - EDIT: I just tested, I'm right) and can be disabled with a registry setting.
RE: HELP REQUEST check if an exe is running by CookieRevised on 06-18-2007 at 05:03 PM

CookieRevised's reply to Restart script through code

The question is, lovefallen: why do you exactly (and in detail) want to stop a script? What is the reason behind it? (and if possible, post your entire code you already got to clarify this).

I ask this because in many cases you do not need to stop a script, or it is even not the required/correct thing todo to perform a certain action and there maybe might be better ways to do what you actually want to do...


RE: HELP REQUEST check if an exe is running by Eljay on 06-18-2007 at 05:09 PM

Please see Eljay's reply to if (program.open)... for an example of how to check if a process is running.


RE: HELP REQUEST check if an exe is running by lovefallen on 06-20-2007 at 06:46 PM

ok here I am: the problem is that Now Playing and Appmon+ can't work together.. and I would like to disable somehow Appmon+ when mediaplayer starts so the song I'm playing is displayed.. I never written a script so probably this is a too much complicated start..


RE: HELP REQUEST check if an exe is running by lovefallen on 06-22-2007 at 11:13 PM

UP


RE: HELP REQUEST check if an exe is running by cooldude_i06 on 06-23-2007 at 04:36 AM

Well Cookie answered your question about restarting a script. About checking if the exe is running, here is the function that I am using for my script IPGet.

code:
function checkProcess(strProcessCaption){
        var wbemFlagReturnImmediately = 0x10;
        var wbemFlagForwardOnly = 0x20;

        var objWMIService = GetObject("winmgmts:\\\\.\\root\\CIMV2");
        var colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Process", "WQL",
                                          wbemFlagReturnImmediately | wbemFlagForwardOnly);
        var enumItems = new Enumerator(colItems);
        for (; !enumItems.atEnd(); enumItems.moveNext()) {
                var objItem = enumItems.item();
                if(strProcessCaption == objItem.Caption) return true;
        }
        return false;
}


RE: HELP REQUEST check if an exe is running by lovefallen on 06-24-2007 at 02:11 PM

thanks to everyone especially CookieRevised and cooldude, I'll try to turn your suggestions into something working!