Jump to content

Recommended Posts

Posted

Hello wonderful community! 

I'm facing a bit of a problem. I'm a security researcher and I'm using AutoIT to automatize testing of some files. 

From time to time, it will happen that when the script executes the file that is being tested a windows error message will pop. This is not an error from my script, but from the tested file itself. These errors make the script pause until I manually click the OK button, then it resumes with no problem.

Is there any way to force the script to resume execution? so far I've tried with WinWait/Winkill, but because the script is paused after the ShellExecute command it never reaches that point. I would have no problem doing it manually, if not for the fact that the system needs to test 1000 files daily.

Here is a sample of the script: 

 

If FileExists($file) Then
        ShellExecute($file)
        Local $handler = WinWait("C:","",30)
        If $handler <> 0 then
            WinKill($handler)
            return 0
        EndIf
    EndIf

 

Thank you! 

Posted (edited)

Well... I thought that WinWait did just that, wait until the msgbox appears? 

The problem is that once the error pops, the script is paused, so WinWait is never executed. And I guess it would be the same with any other function

Edit: I did check Adlib functions and AdlibRegister, and they don't work with MsgBox

Edited by MFrancisca
Posted (edited)

Do you have a screen shot or example of this Windows error message  popup that is causing your script to pause?  It must be a serious error to stop everything on the system from continuing to process. Is this a UAC prompt?  Are you sure it is not your script that is pausing while it waits for something?  Maybe you can post a little more of your script to give the previous snippet a little more context?

Edited by TheXman
Posted

So the file you are testing is causing this error or is it your script because you are not releasing resources properly?  Which resource is insufficient at the time in which the error is displayed (RAM, CPU, HD, ...)?

Posted

Is the file, not my script... I don't know which is the insufficient resource, but as I'm working on a set of virtual machines is not really a problem... or my problem :P I told the development team about this and they said it is expected behavior, I just need to register which files trigger it.

 

 

Posted

If it is a system modal dialog, which it appears to be, it isn't much you can do until the dialog is dismissed.   ¯\_(ツ)_/¯

Posted (edited)

What action causes that to occur.   could be a deadlock on that call, so script is in limbo.  can happen with lots of things.  I get around by starting another process to do that action while the main script waits for the potential window.   if not found, proceed.  search help file for command line to see several examples

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Posted
6 minutes ago, TheXman said:

If it is a system modal dialog, which it appears to be, it isn't much you can do until the dialog is dismissed.   ¯\_(ツ)_/¯

Yeah... I know.. sadly I'm not on development to try and root this behavior out :P

Posted
7 minutes ago, jdelaney said:

What action causes that to occur.   could be a deadlock on that call, so script is in limbo.  can happen with lots of things.  I get around by starting another process to do that action while the main script waits for the potential window.   if not found, proceed.  search help file for command line to see several examples

for command line? Sorry, you lost me a bit there... can you give me some more information, please? 

Posted
1 hour ago, MFrancisca said:

Hello wonderful community! 

I'm facing a bit of a problem. I'm a security researcher and I'm using AutoIT to automatize testing of some files. 

From time to time, it will happen that when the script executes the file that is being tested a windows error message will pop. This is not an error from my script, but from the tested file itself. These errors make the script pause until I manually click the OK button, then it resumes with no problem.

Is there any way to force the script to resume execution? so far I've tried with WinWait/Winkill, but because the script is paused after the ShellExecute command it never reaches that point. I would have no problem doing it manually, if not for the fact that the system needs to test 1000 files daily.

Here is a sample of the script: 

 

If FileExists($file) Then
        ShellExecute($file)
        Local $handler = WinWait("C:","",30)
        If $handler <> 0 then
            WinKill($handler)
            return 0
        EndIf
    EndIf

 

Thank you! 

Since your Statement is in a WinWait wrap your statement in an "IF" then setup a validation to validate the move to the next step. do something similar to what I pasted below.

if the validate returns a error then have the snippet do a WinActivate and a "Send" to automate the pressing of the "Ok" button.

$run_msi = RunWait($msi_command)

If $run_msi > 0 Then SetError($run_msi)
MsgBox(0, "set error", $run_msi)
FileWrite($logfolder & "\" & $swname & ".txt", _Now() & " MSI Exit Errorlevel=: " & $run_msi & @CRLF)
_Close_Open_Apps()

My example above does not include some of the $VAR's

 

Good Luck.

Posted (edited)

This may actually work, thanks! 

I managed to get a bit more information... so the problem is that the ShellExecute command is activated, and while the test file is BEING executed the quarantine kicks in and the tested file is removed. That triggers the error because ShellExecute is trying to access a space of memory that does not exist anymore, and the script is paused because it is stuck on the command. So basicallt I need a way to capture that error status and force ShellExecute to finish

Now, I have to use ShellExcute instead of runwait because the script does not know which type of file will be testing. 

Ok, bacd luck... @Caiaphas, it did not work :(

I guess that because the problem is "inside" a command, not between them my only solution would be to set up a hook so it can monitor the script for errors. Like an external observer.

Does anyone have experience with the _WinAPI UDF? 

Thanks! 

 

 

Edited by MFrancisca
  • Developers
Posted
10 hours ago, MFrancisca said:

Edit: I did check Adlib functions and AdlibRegister, and they don't work with MsgBox

Not your own scrip.msgbox, but will work fine with message-boxes from other programs.

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

  • Developers
Posted
1 hour ago, MFrancisca said:

I some part of the help file I read that the adlib functions do not work with MsgBox because those are blockers..

As I already mentioned: This is only for internal use of the MsgBox() function in the script... this is blocking, but has nothing to do with MsgBoxes generated by another program!
Those cab be perfectly manipulated by AutoIt3.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Hi everybody,

Maybe this code could help anyone who wants to "Resume execution after MsgBox", by running 2 scripts simultaneously

; this script is named "test part 1.au3"
Run(@AutoItExe & " /AutoIt3ExecuteScript " & chr(34) & @ScriptDir & "\test part 2.au3" & chr(34))
MsgBox(4096, "Win1" ,"Hello1") ; will appear 2s max, then close by itself
MsgBox(4096, "Win2" ,"Hello2") ; user has to close this one
; this script is named "test part 2.au3"
While 1
   Sleep(2000)
   If WinExists("Win1") Then
      WinClose("Win1")
   EndIf
WEnd


 

"I think you are searching a bug where there is no bug..."

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
  • Recently Browsing   0 members

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