|
Joined: Apr 2005
Posts: 53
Babel fish
|
OP
Babel fish
Joined: Apr 2005
Posts: 53 |
Is there a way to list the running tasks in the computer?:) And if exists how can I do?:)
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
Try this: alias listprocesses {
echo -ae Listing running processes...
tokenize 32 listprocesses $+ $ticks Error!
.comopen $1tmpa WbemScripting.SWbemLocator
if $comerr { echo 4 -a $2 | goto end }
.comclose $1tmpa $com($1tmpa,ConnectServer,3,dispatch* $1tmpb)
if $com($1tmpb) { .comclose $v1 $com($v1,ExecQuery,1,bstr*,SELECT $&
name $+ $chr(44) $+ executablepath FROM win32_process,dispatch* $1) }
if !$com($1) { echo 4 -a $2 | goto end }
var %i = 1, %a = $comval($1,0)
while %i <= %a {
echo -a $comval($1,%i,name) ( $+ $comval($1,%i,executablepath) $+ )
inc %i
}
.comclose $1
:end
echo -ae Finished listing running processes.
} Type /listprocesses
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: Apr 2005
Posts: 53
Babel fish
|
OP
Babel fish
Joined: Apr 2005
Posts: 53 |
Thanks very much. And I can close with mirc the tasks?
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
alias closeprocess {
tokenize 32 closeprocess $+ $ticks $int($1) $remove($2-,")
if $2 !isnum 0- || $3 == $null { echo -cei info * /closeprocess: invalid parameters | halt }
.comopen $1tmpa WbemScripting.SWbemLocator
if $comerr { echo -cei info * /closeprocess: COM error | halt }
.comclose $1tmpa $com($1tmpa,ConnectServer,1,dispatch* $1tmpb)
if $com($1tmpb) { .comclose $v1 $com($v1,ExecQuery,1,bstr*,SELECT name $&
FROM win32_process WHERE name=' $+ $3-',dispatch* $1) }
if !$com($1) { echo -cei info * /closeprocess: COM error | halt }
if !$2 {
var %i = $comval($1,0)
while %i {
!.echo -q $comval($1,%i,terminate)
dec %i
}
}
else !.echo -q $comval($1,$2,terminate)
.comclose $1
} Syntax is /closeprocess N processname.execloses the Nth running instance of processname.exe. If N = 0, it closes all instances. Example 1: /closeprocess 2 notepad.exe closes the second Notepad window Example 2: /closeprocess 0 notepad.exe closes all Notepad windows
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Some remarks. - Apart from the code you've received, if you are on Windows XP, you can use taskkill, an XP-builtin utility that can kill 1 or more processes in 1 line from within mIRC with /run.
Earlier OS'es are as far as I'm aware not builtin with such tool, but can download Microsoft's kill.exe for example here. It's 35kb, works on any OS, and can be called with /run as well. - The code you got works on Windows ME, 2000, XP, 2003
Windows 95/98/NT4 SP4 users can download WMI from Microsoft in order to make it work here - Code requires mIRC 6.16, because it uses $comval which was only added then.
- More information can be found here: WMI
- Some AVG's like Norton for example might turn off Windows Scripting for safety measures. In this case any code using $com will not work.
- I thought I should add this information for anyone trying out the code, as it will not work if you don't meet 1 or more of the requirements.
|
|
|
|
Joined: Apr 2005
Posts: 53
Babel fish
|
OP
Babel fish
Joined: Apr 2005
Posts: 53 |
Thanks the help guys, it is working for me very good I like it
|
|
|
|
|