Jump to content

Detecting 2 of the same process?


Recommended Posts

#include <Process.au3>

$list = ProcessList("TCP Client.exe")
for $i = 1 to $list[0][0]
  msgbox(0, $list[$i][0], $list[$i][1])
  

msgbox(0,"Process is ",$list[$i][1])
exitloop
Next


$name = _ProcessGetName($list[$i][1])
IF ProcessExists($name) Then
    msgbox(0,"Process","Exiting "&$name&".")
    sleep (1000)
    ProcessClose($name)
EndIf

i can detect just one... i want it to detect 2, then if it finds the second... tell it to exist the first and ignore the second...

anyway to do this?

Edited by backstabbed

tolle indicium

Link to comment
Share on other sites

What...???

:)

lol, I figured I would lose people... heres a better example... |Pid1| and |Pid2| lets say these originated from the same .exe but the same process name still applys "TCP Client.exe". I want it to exit |Pid1| and leave |PID2| alone, thus leaving only one process from the same TCP Client.exe... so the user can't run multiple clients...

That a good example?

Edited by backstabbed

tolle indicium

Link to comment
Share on other sites

  • Moderators

If this is your script/exe then look at _SingleTon in the help file, it will take of the issue for you.

If it is another process, then look at something like:

_ProcessEliminateDupe('notepad.exe')

Func _ProcessEliminateDupe($nPID)
    Local $aPL = ProcessList($nPID)
    $nPID = ProcessExists($nPID)
    If UBound($aPL) - 1 = 1 Then Return 1
    For $iCC = 1 To UBound($aPL) - 1
        If $aPL[$iCC][1] <> $nPID Then ProcessClose($aPL[$iCC][1])
    Next
    Return 1
EndFuncoÝ÷ Ù(hºWdyêmçâ®ËbËZǮ˫xGb´ê)°¢²éÝz»-¢wÝ«­¢+Ù}AɽÍͱ¥µ¥¹ÑÕÁ Ìäí¹½ÑÁ¹áÌäì¤()Õ¹}AɽÍͱ¥µ¥¹ÑÕÁ ÀÌØí¹A%¤(%1½°ÀÌØíA0ôAɽÍÍ1¥ÍÐ ÀÌØí¹A%¤($ÀÌØí¹A%ôAɽÍÍá¥ÍÑÌ ÀÌØí¹A%¤(%%U   ½Õ¹ ÀÌØíA0¤´ÄôÄQ¡¸IÑÕɸÄ(%IÑÕɸAɽÍÍ
±½Í ÀÌØí¹A%¤)¹Õ¹oÝ÷ Ù8Z¶ÈhºW]¢+Dv+v÷§²)©êÚºÚ"µÍÔØÙÜÑ[[Z[]QJ   ÌÎNÛÝY^IÌÎNÊB[ÈÔØÙÜÑ[[Z[]QJ    ÌÍÛQ
BRYPÝ[
ØÙÜÓÝ
    ÌÍÛQ
JHHHHH[]BT]ØÙÜÐÛÜÙJØÙÜÑ^ÝÊ ÌÍÛQ
JB[[
Edited by SmOke_N

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.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...