MFrancisca Posted June 8, 2018 Posted June 8, 2018 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!
Developers Jos Posted June 8, 2018 Developers Posted June 8, 2018 Can't you add an adlib function that checks for these popup message-boxes and take the corrective action? 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.
MFrancisca Posted June 8, 2018 Author Posted June 8, 2018 (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 June 8, 2018 by MFrancisca
TheXman Posted June 8, 2018 Posted June 8, 2018 (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 June 8, 2018 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
TheXman Posted June 8, 2018 Posted June 8, 2018 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, ...)? CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
MFrancisca Posted June 8, 2018 Author Posted June 8, 2018 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 I told the development team about this and they said it is expected behavior, I just need to register which files trigger it.
MFrancisca Posted June 8, 2018 Author Posted June 8, 2018 I'm thinking that that _WinAPI_SetEventHook may be a possible solution, but I'm not sure which event I need to monitor.
TheXman Posted June 8, 2018 Posted June 8, 2018 If it is a system modal dialog, which it appears to be, it isn't much you can do until the dialog is dismissed. ¯\_(ツ)_/¯ CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
jdelaney Posted June 8, 2018 Posted June 8, 2018 (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 June 8, 2018 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.
MFrancisca Posted June 8, 2018 Author Posted June 8, 2018 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
MFrancisca Posted June 8, 2018 Author Posted June 8, 2018 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?
Caiaphas Posted June 8, 2018 Posted June 8, 2018 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.
MFrancisca Posted June 8, 2018 Author Posted June 8, 2018 (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 June 8, 2018 by MFrancisca
Developers Jos Posted June 9, 2018 Developers Posted June 9, 2018 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.
Subz Posted June 9, 2018 Posted June 9, 2018 Are you sure you tried AdLib functions? For example AdlibRegister("_CheckWindow") Local $sFileName = "C:\Windows\Notepad.exe", $iProcess If FileExists($sFileName) Then $iProcess = ShellExecute($sFileName) EndIf While ProcessExists($iProcess) Sleep(100) WEnd ;~ Continue with your script Func _CheckWindow() Local $hWnd = WinExists("C:","") If $hWnd Then WinClose("C:", "") EndFunc
MFrancisca Posted June 11, 2018 Author Posted June 11, 2018 I some part of the help file I read that the adlib functions do not work with MsgBox because those are blockers..
jdelaney Posted June 11, 2018 Posted June 11, 2018 Dialogs and msgbox not originating from your script will not affect adlib 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.
Developers Jos Posted June 11, 2018 Developers Posted June 11, 2018 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.
pixelsearch Posted June 11, 2018 Posted June 11, 2018 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..."
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now