mIRC Home    About    Download    Register    News    Help

Topic Options
#232016 - 14/05/11 01:27 AM Using com to kill a process
pball Offline
Fjord artisan

Registered: 04/11/09
Posts: 295
Sorry for the blatant request, but does anyone have something for killing processes in mirc. I'm guessing using com would be the only way to do it in an mirc script. Thanks for any help.
_________________________
http://scripting.pball.win
My personal site with some scripts I've released.

Top
#232017 - 14/05/11 02:36 AM Re: Using com to kill a process [Re: pball]
FroggieDaFrog Offline
Hoopy frood

Registered: 16/04/10
Posts: 910
Loc: USA
Found you something better, by an old friend of mine, FiberOptics:
Code:
; Usage: /killprocess <N> <process> 
; 
; Examples: 
; 
; /killprocess 0 notepad.exe to kill all processes 
; /killprocess 1 mirc.exe to kill the first instance of mIRC 
; 
; Requirements: mIRC 6.16 and Windows 2k or higher

alias killprocess {
  var %e = echo -ac info * /killprocess:
  if ($version < 6.16) { %e snippet requires mIRC 6.16 or higher | return }
  if ($1 !isnum 0-) || ($0 < 2) { %e <N> <process> with N zero or higher | return }
  var %a = a $+ $ticks, %b = b $+ %a, %c
  .comopen %a WbemScripting.SWbemLocator 
  if ($comerr) { %e error connecting to WMI | return }
  .comclose %a $com(%a,ConnectServer,1,dispatch* %b) 
  if ($com(%b)) .comclose %b $com(%b,ExecQuery,1,bstr*,SELECT $&
    Name FROM Win32_Process WHERE Name = $+(",$2-,"),dispatch* %a) 
  if (!$com(%a)) { %e error retrieving collection | return }
  %c = $comval(%a,0)
  if (!%c) { %e no such process $2 | return }
  if (!$1) {
    while (%c) {
      !.echo -q $comval(%a,%c,Terminate) 
      dec %c 
    } 
  }
  else !.echo -q $comval(%a,$1,Terminate) 
  :error
  if ($com(%a)) .comclose %a
  if ($com(%b)) .comclose %b
}



Edited by FroggieDaFrog (14/05/11 02:40 AM)
_________________________
I am SReject
My Stuff

Top
#232019 - 14/05/11 05:50 AM Re: Using com to kill a process [Re: FroggieDaFrog]
pball Offline
Fjord artisan

Registered: 04/11/09
Posts: 295
Thanks that's exactly what i was imagining.
_________________________
http://scripting.pball.win
My personal site with some scripts I've released.

Top