hydroxide Posted November 10, 2009 Share Posted November 10, 2009 (edited) My setup involves an outer script that runs compiled autoit EXEs from a folder in one after one. There are chances that a few EXEs among the compiled ones may have syntax errors/bad code which results in an "AutoIt Error", line -1 popup. Now, I need to have the outer script detect if there's a popup after running the EXE, and if it is an "AutoIt Error" then kill that particular EXE and move on with the rest. However, I'm somehow unable to get it working. Here's how you can reproduce the problem: Create two files: [1] good.au3, which has just one line of code Msgbox(0,"YAY", "I work") [2] bad.au3, which has one line of bad code Msgbox() Convert both files to their respective EXEs And now the wrapper program 'wrap.au3' Opt("WinTitleMatchMode",2) $pid = Run(@ComSpec & "/c'" & "copy.exe", "", @SW_HIDE) If WinExists("AutoIt Error") Then ProcessClose($pid) Else ProcessWaitClose("copy.exe") Endif Msgbox(0,"DONE EXECUTING",$pid) Now, what I do is make a copy of either 'good.exe' or 'bad.exe' as 'copy.exe' and run the above code. [1] When I run good.exe the code runs fine. [2] When I run bad.exe, the AutoIt Error remains active and the wrapper is unable to get rid of it -- When I change to WinExists("AutoIt") Both good and bad get killed immediately. Somehow 'AutoIt' tends to match both. -- I've tried If WinActive("AutoIt Error") as well. That didn't work. In all cases, either both persist or both get killed. I want the good exe to persist and wait till it closes, while the exe that throws the error to get killed immediately. Any other suggestions? Thanks in advance, Edited November 10, 2009 by hydroxide Link to comment Share on other sites More sharing options...
whim Posted November 10, 2009 Share Posted November 10, 2009 $pid = Run(@ComSpec & "/c'" & "copy.exe", "", @SW_HIDE)note that this will return cmd.exe's PID, not copy.exe's ... whim Link to comment Share on other sites More sharing options...
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