getinfo {
if ($isid) && ($1) && ($prop) {
if ($com(Locator)) { .comclose Locator }
if ($com(Services)) { .comclose Services }
if ($com(Instances)) { .comclose Instances }
.comopen Locator WbemScripting.SWbemLocator
if ($comerr) { .comclose Locator | return }
var %com = $com(Locator,ConnectServer,3,dispatch* Services)
.comclose Locator
if $com(Services) {
var %com = $com(Services, InstancesOf,3,string,$$1,dispatch* Instances)
.comclose Services
}
if $com(Instances) {
var %com = $com(Instances,Count,3)
var %r = $comval(Instances,$iif($2,$2,1),$prop)
.comclose Instances
}
return %r
}
}
processes {
echo -a Number Of Processes: $getinfo(Win32_OperatingSystem,1).NumberOfProcesses
var %x = 1
while (%x <= $getinfo(Win32_OperatingSystem,1).NumberOfProcesses) {
echo -a ( $+ %x $+ ) Process: $getinfo(Win32_Process,[ %x ]).Caption (Priority: $getinfo(Win32_Process,[ %x ]).Priority $+ )
inc %x
}
}
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
}
count_processes {
var %a = a $+ $ticks, %b = b $+ %a, %c
.comopen %a WbemScripting.SWbemLocator
.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 LIKE $+(",$1,"),dispatch* %a)
%c = $comval(%a,0)
if ($com(%a)) .comclose %a
if ($com(%b)) .comclose %b
return %c
}