$process
Posted by Parasite-FT-
Monday, October 04, 2004
Description: Gives info about or terminates Nth process

Ghost2 just made an '$isproc' ident to determine if a process is running, however this will allow you to get information on any/all processes running (this has only been tested on XP, and only on my client at that).

You can find a list of all the properties available at the following link: MSDN [msdn.microsoft.com]

A few examples:
echo $process(0).Name <-- returns the number of processes running
echo $process(1).Name <-- returns the name of the 1st process
echo $process(1).ExecutablePath <-- returns the file path of the process
echo $process(1).Terminate <-- terminates the 1st process

I got a lot of this from the $com tut by ShredPlayer on mircscripts.org so the credit should go there. Hope this is useful to someone :o

Cheers,
- Para


;; Function: returns the Nth process info
;; Usage: $process(<N>)<.property>
alias process {
  .comopen A WbemScripting.SWbemLocator
  if ($com(A)) .comclose A $com(A,ConnectServer,3, dispatch* B)
  if ($com(B)) .comclose B $com(B,ExecQuery,3,string,SELECT * FROM Win32_Process,dispatch* C)
  if ($com(C)) { var %return = $comval(C,$1,$prop) | .comclose C }
  return %return
}
/processes
Posted by Parasite-FT-
Monday, October 04, 2004 11:34pm PDT
gives a list of running processes. It's based upon, but does not use, the $process snippet.


alias processes {
  .comopen A WbemScripting.SWbemLocator
  if ($com(A)) .comclose A $com(A,ConnectServer,3, dispatch* B)
  if ($com(B)) .comclose B $com(B,ExecQuery,3,string,SELECT * FROM Win32_Process,dispatch* C)
  if ($com(C)) {
    var %i = 1
    while ($comval(C,%i,Name)) {
      echo -s $ord(%i) Process: $ifmatch ( $+ $comval(C,%i,CommandLine) $+ )
      inc %i
    }
    .comclose C
  }
}
Subject line
Posted by Ghost2-b
Monday, October 04, 2004 11:47pm PDT
leet
:o
Posted by Psycho
Wednesday, October 06, 2004 07:23pm PDT
Any chance this will get PID's?
yep
Posted by Parasite-FT-
Wednesday, October 06, 2004 11:48pm PDT
yep, I guess my link doesn't work (i'll fix it later), but it should show a list of all the valid properties. ProcessID is one of the properties you can use and will return the pid of the Nth process.

ie, $process(5).processid

- Para
Subject line
Posted by Psycho
Thursday, October 07, 2004 02:04pm PDT
Kickass. Time to make a pointless dialog on this. :)
link fixed
Posted by Parasite-FT-
Thursday, October 07, 2004 05:17pm PDT
i fixed the link.

hehe, great to see someone using a snippet, even if it proves to be 'pointless' - although i find that no script will be pointless.

- Para
Link again.
Posted by Psycho
Saturday, October 09, 2004 01:28pm PDT
para, might wanna check that link, dunno if it's just me, but it didn't redirect to the link, just a links page.

http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_process.asp

That's the link you tried to refer to, I believe.
Submit a comment
Oops! You need to login or register before you can post a comment!

ebaum's world