mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2003
Posts: 144
M
Vogon poet
OP Offline
Vogon poet
M
Joined: Aug 2003
Posts: 144
Hi ppl

I am trying to do a identifier that will check if a process is running.

I have already search on forum but i only have found a code that displays all process running, this one. But i need something that will look directly if the process is running.

Something like:

if the identifier retrieves 0 the process is not running
if the identifier retrieves 1 the process is running

Thanks for all...

Last edited by Miguel_A; 29/12/08 12:39 AM.
Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
Code:
alias process {
  .comopen Process WbemScripting.SWbemLocator
  noop $com(Process,ConnectServer,3, dispatch* Win32_Process)
  noop $com(Win32_Process, ExecQuery,3,string,Select * from Win32_Process,dispatch* Win32_Process_Result)
  var %a = $comval(Win32_Process_Result,0)
  set -l $+(%,process,$1)
  while (%a) {
    if ($comval(Win32_Process_Result,%a,Name) == $1) {
  if ($prop == isopen) { var %t 1 | break }
      elseif ($prop == kill) { var %n 1 | noop $comval(Win32_Process_Result,%a,Terminate) | break }
      elseif ($prop == Nb) inc $+(%,process,$1)
    }
    dec %a 
  }
  .comclose process 
  .comclose win32_process 
  .comclose Win32_Process_Result 
  return $iif(%t,$true,$iif(%n,$true,$iif($var(%process*,0),$var(%process*,1).value,$false)))
}

$process(name).isopen return $true/$false
$process(name).kill kill the processus
$process(name).nb return how many processus is open for this name



#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2003
Posts: 144
M
Vogon poet
OP Offline
Vogon poet
M
Joined: Aug 2003
Posts: 144
woww very nice...
On the msdn site i have try the WshScriptExec Object but that one is to execute the programs, or at least it have executed the program.
I have try the WshNamed Object but this one is always returning the value "0".
Have try several other but with out any good result

How do you know what object/word to use ?

Thanks

Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
ha ha, i'm sorry but it's not my snippet (at least not the part concerning com object), and i don't know much about them, i hope someone here could explain you something :]


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Maybe the "isrun" alias you find in this post is closer to what you have in mind.
The alias is a simple modification of another alias by myggan tho, as I'm no com guru as well smile

Joined: Aug 2003
Posts: 144
M
Vogon poet
OP Offline
Vogon poet
M
Joined: Aug 2003
Posts: 144
Hi

Many thanks for the help Horstl...
I would like to learn com objects but it seems a little difficult.

Both scripts are very nice, and both are working great.
My difficulty now is what script should i choose, hehehe

Well ... by by and a happy new year to all.

Last edited by Miguel_A; 29/12/08 10:14 PM.

Link Copied to Clipboard