Jump to content

Commands not executing after "ShellExecute"


Recommended Posts

Hi all,

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?

2017-07-12_11-00-03.bmp

Link to comment
Share on other sites

  • Developers

Welcome,

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?

Jos

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Hi Jos,

Thanks for the tip about the CodeBox, didn't realize that was an option:

#RequireAdmin
ShellExecute  ("setup.exe", "", "\\bbna-kasp\KLSHARE\PkgInst\Install Endpoint Security (10.3.0.6294) and Network Agent (10.4.343)")
WinWaitActive ("Installing Kaspersky Lab applications", "")
ControlClick ("Button1", "Start installation", 6)
WinWaitActive ("Installing Kaspersky Lab applications", "Close", 2)
ControlClick ("Button1", "Close", 2)
Exit

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. 

Link to comment
Share on other sites

  • Developers

Well, your ControlClick() statements are wrong for sure now I look at them. The first 2 parameters should be Title and Text, which are missing!

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 4 weeks later...

Hi, 
I have similar problem. Looks like I cannot attach my code to correct window.

#include <MsgBoxConstants.au3>

Func Example ()

   ;$HWND_Installer = WinWait("Installer Language", "Please select a language.", 10)
   $HWND_Installer = WinGetHandle("Installer Language", "Please select a language.")

   $btnOK = ControlGetHandle($HWND_Installer, "", "Button1")
   ControlClick ( $HWND_Installer, "", $btnOK)
   ControlClick ("Installer Language", "Please select a language.", $btnOK)

   ;MsgBox (0, "Installer", "$HWND_Installer = " & $HWND_Installer & @CRLF & "$btnOK = " & $btnOK)

   WinClose($HWND_Installer)
   WinClose("Installer Language", "Please select a language.")

EndFunc   ;==>Example

Example()

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.

Installer.png

Link to comment
Share on other sites

  • 4 weeks later...
  • Developers

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.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Here it is: 
 

#include <MsgBoxConstants.au3>

Func Example ()
   Local $iPID = ShellExecute ("Installer.exe", @ScriptDir )

   $HWND_Installer = WinWait("Installer Language", "Please select a language.", 10)
   ;$HWND_Installer = WinGetHandle("Installer Language", "Please select a language.")

   $btnOK = ControlGetHandle($HWND_Installer, "", "Button1")
   ControlClick ( $HWND_Installer, "", $btnOK)
   ControlClick ("Installer Language", "Please select a language.", $btnOK)

   ;MsgBox (0, "Installer", "$HWND_Installer = " & $HWND_Installer & @CRLF & "$btnOK = " & $btnOK)

   WinClose($HWND_Installer)
   WinClose("Installer Language", "Please select a language.")

EndFunc   ;==>Example

Example()

 

Link to comment
Share on other sites

Jos - I realized that you were right about administrative rights. 
Now I built .au3 file into .exe and called right-click > Run as administrator - it works. Buttons are clicked and window closes. 

When asking a question, I just used F5 button (Tools > Go) in SciTE editor to run. Is it possible to run the script with administrative rights without building it into EXE?

Edited by Elena
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...