mIRC Home    About    Download    Register    News    Help

Print Thread
#232016 14/05/11 12:27 AM
Joined: Nov 2009
Posts: 295
P
pball Offline OP
Fjord artisan
OP Offline
Fjord artisan
P
Joined: Nov 2009
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.
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
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
}


Last edited by FroggieDaFrog; 14/05/11 01:40 AM.

I am SReject
My Stuff
Joined: Nov 2009
Posts: 295
P
pball Offline OP
Fjord artisan
OP Offline
Fjord artisan
P
Joined: Nov 2009
Posts: 295
Thanks that's exactly what i was imagining.


http://scripting.pball.win
My personal site with some scripts I've released.

Link Copied to Clipboard