Get process Id from process name menu

User Tag List

Results 1 to 3 of 3
  1. #1
    kantaki's Avatar Member
    Reputation
    5
    Join Date
    Oct 2008
    Posts
    48
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Get process Id from process name

    I am using Scala and I couldn't find something that would give me the PrcoessID from the Processname. Neither in Java, Scala or Winapi.

    At the moment I am using
    Code:
    FindWindowA
    and
    Code:
    GetWindowThreadProcessId
    , but I would prefer something that would give me an array

    Code:
    val process: Array[Int] = GetProcessIdFromExeName("Notepad") // scala code
    So if I would have 10 instances of Notepad, I could access them with
    Code:
    process(0-9)
    I know that something like this exists in .NET, but is there something similar in the WINAPI or Java/Scala?

    Get process Id from process name
  2. #2
    giggling's Avatar Member
    Reputation
    1
    Join Date
    Jul 2010
    Posts
    9
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't remember where I got this from, but:

    Code:
        try {
            String line;
            Process p = Runtime.getRuntime().exec
            (System.getenv("windir") +"\\system32\\"+"tasklist.exe");
            BufferedReader input =
                    new BufferedReader(new InputStreamReader(p.getInputStream()));
            while ((line = input.readLine()) != null) {
                System.out.println(line); //<-- Parse data here.
            }
            input.close();
        } catch (Exception err) {
            err.printStackTrace();
        }

  3. #3
    kantaki's Avatar Member
    Reputation
    5
    Join Date
    Oct 2008
    Posts
    48
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah thanks i found it 30min ago ^^

    here is the scala version

    Code:
    object Main extends App {
      try {
        var line: String = ""
        var p = Runtime.getRuntime().exec("tasklist.exe");
        var input = new BufferedReader(new InputStreamReader(p.getInputStream()));
        var b = true
        while ((line = input.readLine()) != null && b) {
          if (line == null)
            b = false
          println(line)
        }
        input.close();
      } catch {
        case e: Exception => e.printStackTrace()
      }
    }
    Didn't find a scala bufferedreader yet, so it looks pretty ugly :X

Similar Threads

  1. c# get processes the good
    By royalxm in forum Programming
    Replies: 1
    Last Post: 01-22-2012, 05:01 PM
  2. Getting Process ID
    By WhiteShizzle in forum Programming
    Replies: 0
    Last Post: 12-25-2009, 03:46 PM
  3. Changing Process Name
    By Macalese in forum World of Warcraft General
    Replies: 4
    Last Post: 09-30-2007, 09:20 AM
  4. Possible to get perm bann from scamming?
    By gangstas in forum World of Warcraft General
    Replies: 2
    Last Post: 01-23-2007, 04:42 AM
  5. Put fake auction up and get a shard from it
    By Destar in forum World of Warcraft Exploits
    Replies: 17
    Last Post: 12-05-2006, 09:44 PM
All times are GMT -5. The time now is 02:36 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search