Jump to content

Loops then...dies?


 Share

Recommended Posts

Ok, I simply wanted to make a small app that would scan for internet explorer and kill it (I have adware I knew i was installing but now it's uninstalled but sometimes still works >_>) I use firefox to browse the interner so I don't need IE for anything, but I don't want to uninstall it and I tried to overwrite the exe with a quick self closing app but it just overwrites it with the old IE every 5 seconds. So here's my source...

TrayTip ( "Status: Ready", "Internet Explorer killer is now scanning for Internet Explorer and is ready to kill it.", 10 );
    sleep(5000);
    call("IExploreCheck");
    
    Func IExploreCheck();
        $PID = ProcessExists("iexplore.exe");
        if $PID then
            call("IExploreKill")
        Else
            call("IExploreWait")
            EndIf;
    EndFunc;
    
    Func IExploreKill();
        $PKill = ProcessClose("iexplore.exe");
        If $PKill = 1 then TrayTip ( "Status: IExplore Killed", "Internet Explorer has been detected and has been immdeiately closed.", 10 );
        sleep(2000);
        call("IExploreCheck");
    EndFunc;
    
    Func IExploreWait();
        sleep(2000);
        call("IExploreCheck");
        EndFunc;

And yes, I know I don't need the ; after everything, it's habit from C++ >_>. Basically this app when compiled with aut2exe will run for a while, but in task manager it shows its mem increasing slowly and steadily, like 16/second, until it closes after a certain amount, which ends up being like 2 minutes. I figure this is a infinte loop protection feature of AutoIt 3, can anyone help me get past it? Why does its mem keep going up? I can't go much faster than 200 millisecond wait because then it also starts eating up CPU which I can't have. Help please? I know this is a very newbie question, and the search isn't helpful because there are so many unrelated posts containing the keywords...

Edited by GMXeon
Link to comment
Share on other sites

I think your in a recursive loop - Maximum depth of recursive function calls: 384 levels

Im not quite sure thats the problem, but have a try with this.

TrayTip ( "Status: Ready", "Internet Explorer killer is now scanning for Internet Explorer and is ready to kill it.", 10 );
    
    Func IExploreCheck();
        if ProcessExists("iexplore.exe") then
            $PKill = ProcessClose("iexplore.exe");
             If $PKill = 1 Then
                 TrayTip ( "Status: IExplore Killed", "Internet Explorer has been detected and has been immdeiately closed.", 10 );
             EndIf
        EndIf
    EndFunc
    
   While 1
        sleep(2000);
        IExploreCheck();
   WEnd
Edited by Shevilie

Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Link to comment
Share on other sites

I see why the RAM uses increases, it's because you kept on calling functions within eachother.

This could be your solution;

TrayTip ( "Status: Ready", "Internet Explorer killer is now scanning for Internet Explorer and is ready to kill it.", 10 );
While 1
    If ProcessExists("iexplore.exe") Then
        $PKill = ProcessClose("iexplore.exe")
        If $PKill = 1 then TrayTip ( "Status: IExplore Killed", "Internet Explorer has been detected and has been immdeiately closed.", 10 )
    EndIf
WEnd

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

Hi,

#NoTrayIcon

HotKeySet("!{ESC}", "Close") ;Alt + Esc to quit

Global $n = 0

While 1
    ToolTip ("Number Of IE Kills: " & $n & @LF & "Alt + Esc to quit", -1, -1,  "IE Killer Active.")
    ProcessWait("iexplore.exe")
    ProcessClose("iexplore.exe")
    ProcessWaitClose("iexplore.exe", 250)
    $n += 1
WEnd

Func Close()
    Exit
EndFuncoÝ÷ Øay-ìÊØ^r^Á«"·¬mõ®'§vìȶ+b·¥åÊZ(¦'íèÆh­êk¡Ç¬²+(¥éÞvn±§]yÖ¤Y¢éí@u×j-ì­¡ë[~Ç-¢«¢´(^z»v+Rëâ'²V§è¶'Ê¢Øaj÷ºÚ"µÍÌÍÔÚ[HØÙÜÐÛÜÙJ ][ÝÚY^ÜK^I][ÝÊBY   ÌÍÔÚ[HH[
Correct me if I'm wrong but..

ProcessClose() doesn't have a return or so it says in the help file...

So checking if $PKill = 1 seems sorta redundant... am I missing something there?.. lol

Edited by smashly
Link to comment
Share on other sites

Correct me if I'm wrong but..

ProcessClose() doesn't have a return or so it says in the help file...

So checking if $PKill = 1 seems sorta redundant... am I missing something there?.. lol

TrayTip ( "Status: Ready", "Internet Explorer killer is now scanning for Internet Explorer and is ready to kill it.", 10 );
While 1
    If ProcessExists("iexplore.exe") Then
        $PKill = ProcessClose("iexplore.exe")
        If $PKill = 1 then TrayTip ( "Status: IExplore Killed", "Internet Explorer has been detected and has been immdeiately closed.", 10 )
        MsgBox(0,"", $PKill)
    EndIf
WEnd

Despite what's written in Helpfile, $PKill returns 1 when ProcessClose() succeeded. If the check is not in place, you'll receive the TrayTip() that it was a success even if ProcessClose() failed.

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

Why not spend your efforts fixing the problem instead of the symptoms? I think you'd be better off getting rid of the malware on your system instead of writing scripts to close IE whenever it opens. Maybe that's just me...

Link to comment
Share on other sites

I do agree with HeffeD view , but original the question was to fix a loop in a script.

TrayTip ( "Status: Ready", "Internet Explorer killer is now scanning for Internet Explorer and is ready to kill it.", 10 );
While 1
    If ProcessExists("iexplore.exe") Then
        $PKill = ProcessClose("iexplore.exe")
        If $PKill = 1 then TrayTip ( "Status: IExplore Killed", "Internet Explorer has been detected and has been immdeiately closed.", 10 )
        MsgBox(0,"", $PKill)
    EndIf
WEnd

Despite what's written in Helpfile, $PKill returns 1 when ProcessClose() succeeded. If the check is not in place, you'll receive the TrayTip() that it was a success even if ProcessClose() failed.

ProcessClose() will also return 1 if it fails , so it sorta blows your theory out the water about showing a tooltip only on success.

since $PKill will always equal 1 in your loop along with your cpu usage will always be maxed out using your code as it is...

Cheers

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