Commands not executing after "ShellExecute"

15 posts in this topic

aarellan 0

New member/AutoIT user here. I'm trying to create a simple automation script that will launch a setup file I've created for Kaspersky. When I run the script below, the ShellExecute function runs as intended and brings up my setup file, but does not proceed with any further commands. I've noticed that after my setup file pops up, the script terminates itself shortly afterwards (no Script Pause, it just exits). I've referenced help documentation on AutoIT's site for these commands (WinWaitActive and ControlClick), and it seems like I have the syntax correct. I obtained the information in the commands using the WindowInfo tool. What am I doing wrong here?

Share this post

Link to post

Share on other sites

Jos 1,114

Please put the code you like to show in a CodeBox (<>) with cut&Paste in stead of adding an image as that makes it much harder to help.
If the code just ends without any errors it means the WinWaitActive(s) were successful and ControlSend(s) were performed.

Why aren't you using the Silent option for the installer in the first place as that should be much less error prone?
Isn't the installer asking for Admin level or are you shelling the script at that level already?

I've tried to utilize a silent option with the setup installer, but I can't get that to work either. That's why I wanted to try out AutoIT to automate the mouse clicks I need.

It doesn't seem like any of the commands besides ShellExecute are being performed. When my installation window pops up, the "Start installation" button is not clicked, even though I specified that step immediately afterwards. In its current configuration, shouldn't the script wait until my installation window is active, then proceed to click the button I specified? Or did I code that portion wrong?

The installer does require administrative privileges by default, I just read a tip from another post that said including this line may resolve my command execution problems, but it doesn't. When I remove this line, the same issue occurs.

I ran my installer before calling this function, and it is already displayed on the desktop. When I de-comment MsgBox fragment, it correctly displays hWnd variables for my installer, the same I can see with AutoIt Info tool.
But ControlCLick does not work, as well as WinClose (tried with hWnd and title as you can see from code). Please help. I attach my screen with installer window.

Share this post

Link to post

Share on other sites

Jos 1,114

What about you show the whole script as you have now just posted bits and pieces which don't make it clear to me?
You could very well have some sort of timing error, meaning the application is still starting when you perform already functions for it.