Jump to content
Sign in to follow this  

AutoIt should return when script is finished???

Recommended Posts



after some hours of researching i stil have no clue what is going on internally in autoit it.

I am used to unix - so i am seeing autoit as just an another script language - which behaves very strange!

My Goal is simple. I want to start an Auto it script from an VBScript program - and i do not want to the autoit script to return before the script is finished.

Currently i try to run the script

"C:\mypath\autoit3.exe" "myscript"

in VBScript with "wsh.Run(cmdline,0,true)"

However if i start the autoit script (which waits until a "Busy" window disappears - Simple! ) - autoit Returns immediatly.

Even if i try to run this from dos cmdline it

this line returns immediatly - although it correctly displays a message box some 120 secondes later when the busy window has disappeared

"C:\mypath\autoit3.exe" "myscript", the script Returns immediatly

--> so my Programm continues - although the "Busy Window" has not disappeared!

However i want _not_ an immediate return. I want that autoit3.exe Returns exactly when myscript is finished - and not any time earlier!

At this point and a lot research i have no clue how to do this....

Can anybody please advise me?


Share this post

Link to post
Share on other sites

I pressume by 'return' you mean terminate (or maybe you mean a successful script startup). If an AutoIt message box appears later, the script must still be active, so it can not have terminated. Perhaps the script is badly written for the particular purpose. I can't see your script, so I'm afraid I don't have a clue.

Edited by czardas

Share this post

Link to post
Share on other sites

Is there by any chance a #RequireAdmin in the script? Because that will cause AutoIt to restart itself with Admin credentials, which means the original script has terminated and then started a new instance of itself. Unfortunately, that will also mean that the calling VBscript will see that the original program has terminated.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post

Link to post
Share on other sites

Please post your code tried so far.

Read helpfile on

WinWait ( "title" [, "text" [, timeout]] )


WinWaitActive ( "title" [, "text" [, timeout]] )


you need a loop that waits till the exitsituation is there

while $t=False
    sleep 200

;TO DO whatever your situation is to wait for
Edited by junkew

Share this post

Link to post
Share on other sites

Hi, sorry for not posting, but i had to many "Debug" Statements in the code....

Here it is nice and simple (see below). The basic challenge is

VBscript Programm --> Run AutoIt Script --> Wait until AutoIt Script finishes --> contine VBScript Programm.

Or to make it simpler

CMD Line -> Runi AutoiT Script - CMD Line blocks until Script finished

But i cannot get this to work !!!

When i start it on console "autoit3.exe myscript.au3" then the programm immediatly "forks/spawns" and

i can type again in the cmdline, although it should block until it finishes --> the script does exactly what

is meant to be it ends when the window close, however as it as forked/spawned a new process

from the console i have no way to determine when the autoit script has finished....

In AutoIt There is a "RunWait" to Wait for External Programms...

In Unix environemtn, there is always some kind of "do not fork" , "do not create new process" switch, in order to prevent the behaviour i see with AutoIt.


AutoItSetOption("MustDeclareVars", 1)

Dim $window_name

$window_name = "Busy"

; Sleep until Programm is up and running

; Now run until it finishes and the "Busy" Window Disappear
While WinExists($window_name)

MsgBox(0,"Reached End", "Reached End!")
Edited by baldur

Share this post

Link to post
Share on other sites


i finally found a "solution". I have to compile the au3 script to an "console" exe programm. This way i get the expected behaviour. The exe ends when the compiled au3 script is finished...

This was a tough one... and still, why i must compile this? I 'd rather like to live without a compiled script.

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