detection process in windows xp, vista, seven.

B

Beusse Beusse

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.
 
P

Phillip Gawlowski

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 Gawlowski

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.
 
L

Luis Lavena

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.
 
J

John Allen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,054
Latest member
LucyCarper

Latest Threads

Top