Jump to content

process exists


Recommended Posts

thx, i have read most help files, but I have already figured out how to do that.

But I don't understand how to add in the script that it should exit any process that starts and not just a process I've choosen.

How are we to know?

that was my first idea, but i didn't come up with an idea of how to compare them.

*duh*

so far i've only made this idea in my head, so I haven't started to write yet...

I guess that explains why you don't have an ide of how to compare two array lists.

So to conclude @matumbo. You want a little program to play mischief with your friends (and others). but you don't want to do anything of it yourself so you just throw out the question and try to fish until someone is kind/stupid enough to do the work for you?

Happy Scripting..:)

Link to comment
Share on other sites

That wasn't really my thought, i'm just learning as much as I can about autoit, and when I get an idea I try to find a function that can execute the idea,

and I don't mean any harm with my scripts.

I'm sorry if that was the first impression.

Edited by matumbo
Link to comment
Share on other sites

harm, no, I don't think you do mean any harm.

Lazy... yes, you are being very lazy about this.

When you try to write a script... first step is TRY, you missed that one

If you try and fail, show us your failed script and we can help you fix it.

If you don't try at all and just have ideas, then you are fishing for somebody to turn your ideas into a script.

I am more than willing to help you with this, but I need to see at least SOME effort

Link to comment
Share on other sites

Leave the fighting up to me fellas. Here is the solution.

;Store current processlist "state"
$ListOne = ProcessList ()

While 1
    $ListTwo = ProcessList ()
    
    ;Verify each process exists in original state, if not, KILL IT!!!!!!!!!!!!!!!! 
    For $X = 1 to $ListTwo[0][0]
        $found = false
        
        ;Comparing by process name, I suppose process ID would work too
        For $Y = 1 to $ListOne[0][0]
            If $ListOne[$Y][0] = $ListTwo[$X][0] Then
                $found = true
                ExitLoop
            EndIf
        Next
        
        ;DIE YOU SON OF A BITCH PROCESS!!!!
        If $found = false Then
            ;Close by PID
            MsgBox(0,"","Closing rogue process: " & $ListTwo[$X][0])
            ProcessClose($ListTwo[$X][1])
        EndIf
    Next
    
    ;Check every 3 seconds
    Sleep (3000)
WEnd
Link to comment
Share on other sites

Dually noted Dr. Willi:

;Store current processlist "state"
$ListOne = ProcessList ()

While 1
    $ListTwo = ProcessList ()
    
    ;Verify each process exists in original state, if not, KILL IT!!!!!!!!!!!!!!!! 
    For $X = 1 to $ListTwo[0][0]
        $found = false
        
        ;Comparing by PID, because danwilli would prefer it
        For $Y = 1 to $ListOne[0][0]
            If $ListOne[$Y][1] = $ListTwo[$X][1] Then
                $found = true
                ExitLoop
            EndIf
        Next
        
        ;DIE YOU SON OF A BITCH PROCESS!!!!
        If $found = false Then
            ;Close by PID
            MsgBox(0,"","Closing rogue process: " & $ListTwo[$X][0])
            ProcessClose($ListTwo[$X][1])
        EndIf
    Next
    
    ;Check every 3 seconds
    Sleep (3000)
WEnd

Funny thing happened when I posted this. I accidentally left this script running and when I posted this comment from Firefox a message popped up saying potdata.exe had to be closed...must be part of firefox.

Edited by weaponx
Link to comment
Share on other sites

Another example, using WMI and Asynchronous Events (gleamed from a few posts here on the forums, tested to be working):

Dim $strComputer = ".", $strQuery, $SINK, $objContext, $objWMIService, $objAsyncContextItem, $return, $account
$strQuery = "SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_Process'"
$SINK = ObjCreate("WbemScripting.SWbemSink")
ObjEvent($SINK, "SINK_")
$objContext = ObjCreate("WbemScripting.SWbemNamedValueSet")
$objWMIService = ObjGet("winmgmts:!\\" & $strComputer & "\root\cimv2")
If Not @error Then
    $objWMIService.ExecNotificationQueryAsync ($SINK, $strQuery, Default, Default, Default, $objContext)
EndIf
ConsoleWrite("In monitoring mode. Press Ctrl+C to exit." & @CRLF)
While 1
    Sleep(10000)
WEnd

Func SINK_OnObjectReady($objLatestEvent, $objAsyncContext)
    ;Trap asynchronous events.
    ConsoleWrite("Closing " & $objLatestEvent.TargetInstance.Name & "(" & $objLatestEvent.TargetInstance.ProcessID & ")" & @CRLF)
    ProcessClose($objLatestEvent.TargetInstance.ProcessID)
EndFunc   ;==>SINK_OnObjectReady
Link to comment
Share on other sites

thanks to everybody really much that helped, i'm sorry that i didn't show you my efforts danwilli but every thing I tried failed, and it felt a bit awkward to show them because I didn't know if they were right at all.

Edited by matumbo
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...