Sign in to follow this  
Followers 0
Mullhew

Ending a script

3 posts in this topic

Hi all,

I'm relatively new to AutoIT scripting, but I've had some success creating simple scripts to aid in my automation of building new PC's for my employer. However, I am having problems scripting an end to my scripts. The 'Exit' command is being flat out ignored. I've even tried scripting an end E.G. run("taskkill /f blahblah.exe"). I've also tried batch scripting through a dos acript, but the taskkill isn't being started as the script is still being run.

As an example, here is my simplest AutoIt script:

run ("\\servername\foldername\Bin\Win32\X86\HPCMS\Agent\HPCMSSetup.exe")

winwaitactive("HPCMSAgent", "OK")

send("{ENTER}")

It's an HP agent that allows me to modify BIOS settings for PC's. I have various applications that run via AutoIT as well, but no matter how simple or complex the script is it wont end itself. I have to go in and manually turn the script off (right click on icon in task bar, select exit).

As I've said, adding 'Exit' (without the 's ) is ignored by any machine other than the one I am compiling the script on. It runs fine on my machine where I build the script. I've googled the problem, and can find nothing pertinent. Help! I feel I must be missing something obvious. What is it though?

Share this post


Link to post
Share on other sites



OK, first of all, WELCOME!

In your sample code, this script would "hang" because of your choice of command. winwaitactive does just what it is designed to do...wait until the window is active. If it never exists or it is never active, that script will not get past this line. A better way to to do this is with a timeout specified:

Run("\\servername\foldername\Bin\Win32\X86\HPCMS\Agent\HPCMSSetup.exe")
If WinWaitActive("HPCMSAgent", "OK", 10) Then   ;Wait 10 Seconds For Window To Become Active
    Send("{ENTER}")
Else
    Exit MsgBox(0, "Error", "Window Never Became Active", 5)
EndIf
If you post more code, we would be glad to help you solve your problem. In short, it is more likely that your problem is a logic error than an AutoIT/OS error.

Share this post


Link to post
Share on other sites

Thanks for the quick response! I'm going to give it a try now and see what happens. The compiled script runs as part of a job to build PC's, so I'll image a fresh one to see if it works.

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  
Followers 0