Jump to content
Sign in to follow this  

Unable to kill an AutoIT compiled file

Recommended Posts


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


Convert both files to their respective EXEs

And now the wrapper program 'wrap.au3'

$pid = Run(@ComSpec & "/c'" & "copy.exe", "", @SW_HIDE)
If WinExists("AutoIt Error") Then
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 by hydroxide

Share this post

Link to post
Share on other sites

$pid = Run(@ComSpec & "/c'" & "copy.exe", "", @SW_HIDE)

note that this will return cmd.exe's PID, not copy.exe's ...


Share this post

Link to post
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
Sign in to follow this