detection process in windows xp, vista, seven.

Discussion in 'Ruby' started by Beusse Beusse, Jan 23, 2011.

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

    --
    Posted via http://www.ruby-forum.com/.
    Beusse Beusse, Jan 23, 2011
    #1
    1. Advertising

  2. On Sun, Jan 23, 2011 at 8:48 AM, Beusse Beusse
    <> 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 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.
    Phillip Gawlowski, Jan 23, 2011
    #2
    1. Advertising

  3. Beusse Beusse

    Luis Lavena Guest

    On Jan 23, 4:48 am, Beusse Beusse <> 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.

    --
    Luis Lavena
    Luis Lavena, Jan 23, 2011
    #3
  4. Beusse Beusse

    John Allen Guest

    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

    --
    Posted via http://www.ruby-forum.com/.
    John Allen, Jan 23, 2011
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fangs
    Replies:
    3
    Views:
    9,739
    darshana
    Oct 26, 2008
  2. Leo Wong

    Seven Java Screensavers

    Leo Wong, Mar 1, 2006, in forum: Java
    Replies:
    13
    Views:
    3,407
  3. benny

    Seven Day Rotation Script

    benny, Jan 19, 2004, in forum: HTML
    Replies:
    5
    Views:
    491
    benny
    Jan 20, 2004
  4. David Winter
    Replies:
    4
    Views:
    478
    David Winter
    Jan 10, 2005
  5. Elnikety
    Replies:
    2
    Views:
    1,387
    Elnikety
    May 7, 2007
Loading...

Share This Page