Sign in to follow this  
Followers 0
matumbo

process exists

19 posts in this topic

Any1 have an idea how to make a script that waits until a new process starts and then ends it?

thx in advance.

Share this post


Link to post
Share on other sites



Read up on If/Then, ProcessExists() and ProcessClose()


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Dan, they'll never learn if you spoon feed them.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

lol, I know, im sorry, I was typing while you were submitting :)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

take a look at ProcessList() and then you can (in the loop) check to see if there are any new process' by comparing to that list you made :)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

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

Edited by matumbo

Share this post


Link to post
Share on other sites

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..:)

Share this post


Link to post
Share on other sites

My thoughts exactly, Uten.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Process ID would probably work better, cause then you couldn't open another copy of notepad if you already had one open pre script

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0