; Simple Taskmanager
; Paste it to your remote and type /tasklist
; only tested on winxp prof, should work from 2K and above.
; [update - improved speed a lot xD]
; If you get some errors try: /run cmd /c net start WmiApSrv
alias tasklist {
!var %i,%l,%f,%w = @tasklist,%n = 1
if ($window(%w)) { !clear %w }
wmiclose
!.comopen WMI WbemScripting.SWbemLocator
!noop $com(WMI,ConnectServer,3,dispatch* WMI2)
var %what = Name,ParentProcessId,ProcessId,Priority,CommandLine
!noop $com(WMI2,ExecQuery,3,bstr*,SELECT %what FROM Win32_Process,dispatch* WMIResult)
!window -lekz -t30,38,41,55,75,95 %w
!aline $color(info2) %w Process $+ $chr(9) $+ Parent $+ $chr(9) $+ -> $+ $chr(9) $+ Process ID $+ $chr(9) $+ Priority $+ $chr(9) $+ Commandline
while ($wmiresult(%n).Name) {
!var %Name = $WMIresult(%n).Name
!var %ParentProcessId = $WMIresult(%n).ParentProcessId
!var %ProcessId = $WMIresult(%n).ProcessId
!var %Priority = $WMIresult(%n).Priority
!var %CommandLine = $WMIresult(%n).CommandLine
aline $color(info) %w $&
%Name $+ $chr(9) $+ $&
%ParentProcessId $+ $chr(9) $+ $&
-> $+ $chr(9) $+ $&
%ProcessID $+ $chr(9) $+ $&
$iif(%Priority,$priority($ifmatch),7(unknown)) $+ $chr(9) $+ $&
$iif(%CommandLine,$ifmatch,7(unknown))
inc %n
}
wmiclose
!window -b %w
}
alias -l WMIclose {
if ($com(WMI)) { !.comclose WMI }
if ($com(WMI2)) { !.comclose WMI2 }
if ($com(WMIResult)) { !.comclose WMIResult }
}
alias -l WMIresult {
return $comval(WMIResult,$iif($len($1),$1,1),$prop)
}
alias -l priority {
!var %N/A = 03Not Available;
!var %low = 03Not Available;
!var %lower = 03Lower than normal;
!var %normal_ = 07Normal;
!var %normal = 07Normal;
!var %higher = 04Higher than normal;
!var %high = 04High;
!var %realtime = 06Realtime;
!var %max = 13Above Realtime
!return $iif($gettok($+(%N/A,%low,%lower,%normal,%normal_,%higher,%normal_,%high,%realtime,%max),$findtok(0 4 6 8 9 10 11 13 24 31,$1,1,32),59),$v1,unknown* $+ $1)
}
alias -l pkill {
return $gettok($sline(@tasklist,$1),1,9) $chr(9) $gettok($sline(@tasklist,$1),4,9)
}
menu @tasklist {
Refresh:tasklist
-
$iif(!$sline(@tasklist,2),Kill $gettok($sline(@tasklist,1),1,9) $chr(9) $gettok($sline(@tasklist,1),4,9))
.Process:!run cmd /C taskkill /PID $gettok($sline(@tasklist,1),4,9)
.Kill Process Tree: !run cmd /C taskkill /I /PID $gettok($sline(@tasklist,1),4,9)
.-
.Force Kill: !run cmd /C taskkill /F /PID $gettok($sline(@tasklist,1),4,9)
.Force Process Tree Kill:!run cmd /C taskkill /F /I /PID $gettok($sline(@tasklist,1),4,9)
$iif($sline(@tasklist,2),Kill (multiple selected))
.Kill
..$submenu($_killall($1))
.Kill process tree
..$submenu($_killall($1).tree)
.-
.Force kill
..$submenu($_killall($1).force)
.Force process tree kill
..$submenu($_killall($1).forcetree)
}
alias -l _killall {
if ($isid) {
if ($1 isnum) {
if ($gettok($sline(@tasklist,$1),4,9) isnum) {
if ($prop == forcetree) { return $gettok($sline(@tasklist,$1),1,9) $chr(9) $gettok($sline(@tasklist,$1),4,9) : !run cmd /C taskkill /F /I /PID $gettok($sline(@tasklist,$1),4,9) }
elseif ($prop == tree) { return $gettok($sline(@tasklist,$1),1,9) $chr(9) $gettok($sline(@tasklist,$1),4,9) : !run cmd /C taskkill /I /PID $gettok($sline(@tasklist,$1),4,9) }
elseif ($prop == force) { return $gettok($sline(@tasklist,$1),1,9) $chr(9) $gettok($sline(@tasklist,$1),4,9) : !run cmd /C taskkill /F /PID $gettok($sline(@tasklist,$1),4,9) }
else { return $gettok($sline(@tasklist,$1),1,9) $chr(9) $gettok($sline(@tasklist,$1),4,9) : !run cmd /C taskkill /PID $gettok($sline(@tasklist,$1),4,9) }
}
}
}
}