Detection process in windows xp, vista, seven

Hello everyone.
Is it possible to detect such processes in windows xp, vista, seven?
I need to rise to the name of the desired process.
What would the ruby code if possible?
Thank you.

On Sun, Jan 23, 2011 at 8:48 AM, Beusse B.
[email protected] wrote:

Hello everyone.
Is it possible to detect such processes in windows xp, vista, seven?
I need to rise to the name of the desired process.

Not sure what you mean.

However, if PowerShell is available (which it is on Windows 7, not
sure about Vista, it needs to be installed manually on XP),

system “ps” # similar to the *NIX ps utility, lists PID among other
things

will list all processes the current user can access.

I’m sure there are other ways (with the win32api gem, maybe).


Phillip G.

Though the folk I have met,
(Ah, how soon!) they forget
When I’ve moved on to some other place,
There may be one or two,
When I’ve played and passed through,
Who’ll remember my song or my face.

On Jan 23, 4:48am, Beusse B. [email protected] wrote:

Hello everyone.
Is it possible to detect such processes in windows xp, vista, seven?
I need to rise to the name of the desired process.
What would the ruby code if possible?

tasklist.exe

Use tasklist.exe /? to query for specific processes and see stats
about it.

You can do this:

result = tasklist.exe

And the result of executing that command is stored in result, is now
up to you to parse it.

It is available since Windows 2000 AFAIK.

Are you looking for something like this??:

require ‘win32ole’
wmi =
WIN32OLE.connect(“winmgmts:{impersonationLevel=impersonate}!//./root/cimv2”)

cmdln = false
if ARGV[0]
ps = wmi.ExecQuery(“Select * from Win32_Process Where ProcessId =
#{ARGV[0]}”)
cmdln = true
else
ps = wmi.ExecQuery(“Select * from Win32_Process”)
end
puts " Process Name PID PRI Thd Virtual Size"
puts “================================ ====== === ===
====================”
ps.each do |p|
puts p.Name.ljust(35) + p.ProcessId.to_s.ljust(8) +
p.Priority.to_s.ljust(5) + p.ThreadCount.to_s.ljust(5) +
p.VirtualSize.to_s
if cmdln
puts p.CommandLine.to_s
end
#puts " CMD: " << p.CommandLine.to_s
#puts " PID: " << p.ProcessId.to_s
#puts " Priority: " << p.Priority.to_s
#puts " Threads: " << p.ThreadCount.to_s
#puts " Size: " << p.VirtualSize.to_s
end