Jump to content

Recommended Posts

Posted

How can I detect whether a process is already running?

Not the script itself, there's a function to check that, but a standalone process.

Please help me :mellow:

Thanks in advance.

[right]~What can I say, I'm a Simplistic person[/right]

Posted

How can I detect whether a process is already running?

Not the script itself, there's a function to check that, but a standalone process.

Please help me :mellow:

Thanks in advance.

Use ProcessExists() or ProcessList ().

Posted

With ProcessExists() I can check whether a process exists.. but I know the process exists. I need to know whether it exists twice :(

I'll try ProcessList though :mellow: thanks for the tip.

(NO I'm not closing the process and then running ProcessExists() to see whether the process is still there xD)

[right]~What can I say, I'm a Simplistic person[/right]

Posted (edited)

;Run("notepad.exe"); testing with notepad
;Run("notepad.exe")
$name = InputBox("enter process name", "enter", "notepad.exe")
$list = ProcessList($name)
for $i = 1 to $list[0][0]
    For $t = 1 to $list[0][0]
        If $list[$t][0] = $list[$i][0] And $list[$t][1] <> $list[$i][1] then;checks if there is proccess with SAME name but with DIFFERENT PID.
            MsgBox(0, "process exists twice OR more:", $list[$t][0] & " - PID: " & $list[$t][1] & @CRLF & $list[$i][0] & " - PID: " & $list[$i][1])
        EndIf
    Next
next

try this, i think it will help

if u want to close the most new process - close this one with the higher PID, and if for the first started - the lower PID (i think)

Edited by cheatera

Is There A Life BEFORE Death?im stupidSaved warn logs: cheateraSmOke_N Note Added 17 January 2009 - 02:54 PM Added to warn level Posting a way to hack the registry and force sending someones desktop via TCP. Jos Note Added 25 November 2008 - 02:52 PM Added to warn level for being an impolite rookie.once a year i go bad ... what will happen in 2010??[u]Its GOOD to be BAD ... (Warlock's Succubus - World of Warcraft)[/u]

Posted

what about 3 processes? or u are sure there are only 2? i mean in my example it shows all processes (2,3, ... 55 ... ) but yes yours it simplier :mellow: btw just checked: the most rescent open process is with the higher PID, so if u want to close the most rescent - kill the process with higher PID.

cheerz

Is There A Life BEFORE Death?im stupidSaved warn logs: cheateraSmOke_N Note Added 17 January 2009 - 02:54 PM Added to warn level Posting a way to hack the registry and force sending someones desktop via TCP. Jos Note Added 25 November 2008 - 02:52 PM Added to warn level for being an impolite rookie.once a year i go bad ... what will happen in 2010??[u]Its GOOD to be BAD ... (Warlock's Succubus - World of Warcraft)[/u]

Posted

there can also be 1000 processes, but my script kills each and every one untill only one remains. so that's what I need.

I don't think it matters whether I close the older or the newer.. but I'll check.

[right]~What can I say, I'm a Simplistic person[/right]

  • 2 weeks later...
Posted

How can I detect whether a process is already running?

Not the script itself, there's a function to check that....

sorry to hijack this thread (it seems u've already found a solution) but what is this function that detects whether the script itself is already running?

  • Moderators
Posted

sorry to hijack this thread (it seems u've already found a solution) but what is this function that detects whether the script itself is already running?

Look for _Singleton in the help file.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...