Jump to content

Recommended Posts

Posted

Any way i can detect if my exe is 'end tasked' ? I would like to display a msgbox or write a log file just before the task is closed.

Posted

OnAutoITExitRegister sets @ExitCode & @ExitMethod. I would suggest playing around with that, And seeing how you get on.

Cheers

Javi

give a man an application, and he'll be frustrated for the day, Teach him how to program applications and he'll be frustrated for a lifetime.

Posted

If you close something with task manager, it halts the process and wouldn't register an exit message if I'm not mistaken.

Posted

If you close something with task manager, it halts the process and wouldn't register an exit message if I'm not mistaken.

​Yes , indeed . So how to do it then?

Posted (edited)

Ahh i see your problem now.

A quick google of the subject shows that OnAutoITExitRegister func does not handle script crashes or force closures (Such as task manager). I would advise you have a sub process that monitors your script and is called on startup, Then add an OnExit event that creates a flag with the exit method. If the process no longer exists and the monitor picks it up, It can check for the flag, and if the flag does not exist, The script has either crashed, or been forcefully closed.

A working example:

Main.exe:

OnAutoItExitRegister("exitfunc")

ShellExecute(@WorkingDir & "\TaskMonitor.exe",@AutoItPID)
sleep(10000)

func exitFunc()
    FileWriteLine(@WorkingDir & "\ExitMethod.flg",@exitMethod)
EndFunc

TaskMonitor.exe:

if $CMDLINE[0] = 0 then Exit

while 1
    sleep(10)
    if ProcessExists($CMDLINE[1]) then ContinueLoop
    If FileExists(@WorkingDir & "\ExitMethod.flg") then
        MsgBox(0,0,"Exited via normal method")
        FileDelete(@workingDir & "\ExitMethod.flg")
    Else
        Msgbox(0,0,"Force closed or crashed")
    EndIf
    
    Exit
WEnd

 

Obviously that's a rudimentary example, But hopefully it helps get you on the right tracks.

 

Cheers

Javi

 

EDIT: added file names for example.

Edited by javiwhite

give a man an application, and he'll be frustrated for the day, Teach him how to program applications and he'll be frustrated for a lifetime.

Posted

I'd say @javiwhite has the right idea, but doing it from within the script itself I don't think is possible. I have some scripts on my computer that monitor for when my services crash and automatically restart them (if the process doesn't exist, then it sends a force close to the process name just in case its stuck, then delays 10 seconds and restarts the service and waits 2 minutes).

Posted

I think i remember that it was done some time ago , but cant find the thread. It was using some kind of interception of windows messages.

Posted

Something like this?

This would do essentially what you are talking about, but again, its a different application because when you end a thread on task manager, you would need another application to catch the message because the thread has been halted and can no longer perform any functions. Its pretty easy to pack each script as an exe then create a launcher so the launcher can run in the background and capture exit codes and errors. I've even got compile commands set in some of my scripts to compile the subapps so I can deploy everything all at once. If you want an example I'll post it.

Posted

@Jewtus: I will have a look. Basically what the elegant way was doing was to intercept the 'end task' , and prevent it from executing. Then write a log / display msgbox and shutdown the app.

Posted (edited)

@Jewtus: I will have a look. Basically what the elegant way was doing was to intercept the 'end task' , and prevent it from executing. Then write a log / display msgbox and shutdown the app.

​well i guess this is how you create virus if you can manage to interupt it and prevent from executing end task...... curious anyone willing to share how it can be done

Edited by zreo15
Posted (edited)

Isn't using autoit for game bots and malware against the rules?

Juvi, out of boredom I did some searching and from what I see about other programming languages and executions on windows, the only things that cannot be end tasked are windows services (native windows services... so creating a service might not work) since windows 98.

<snip>

Edited by Melba23
Suggestion removed
  • Moderators
Posted

Juvigy,

Basically what the elegant way was doing was to intercept the 'end task' , and prevent it from executing.

 Not something we want to discuss here - thread locked.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Guest
This topic is now closed to further replies.
×
×
  • Create New...