Jump to content

ControlClick


Recommended Posts

Hey everyone. I've come across an issue with a script I've been working on to automate the removal of prior versions of AVG and install the latest version, however the script gets to a certain point and stops, without erroring out.

Essentially, everything up to ControlClick("Warning", "&Yes", 6) works fine. The script will write the registry keys correctly, and unregister and register the MSI service, and then checks to see if one of the 3 folders listed exist. If it finds one of the 3 folders, it starts the AVG removal tool.

At that point, the AVG Removal tool has a window that pops up with the title "Warning", with some text, and a Yes or No button. Clicking Yes continues the removal, but as the script currently sits, it doesn't click anything. I've attemped to use WinActive, ControlSend, and ControlClick using the data I gathered from AutoIt Window Information with no success. I'm a little curious if the section with the comment "; Check for prior versions of AVG" is coded correctly. I'd appreciate it if anyone could give me a bit of help.

P.S.

The latter part of the code is added as well, including the RunOnce key which starts the InstallAVG function, so when I reboot the machine, it automatically logs into my admin account and tries to start the AVG installation.. It's just the bit with trying to figure out the deal with why it wont click the Yes button on the warning prompt after AVG Removal tool is started.

Also, this is AutoIt v3.3.6.1

Any help is appreciated!

#RequireAdmin

; Automatic Login after reboot
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName", "REG_SZ", "****")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword", "REG_SZ", "****")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon", "REG_SZ", 1)

; Unregister and Re-register MSI service (sometimes causes AVG installation to error out)
RunWait(@ComSpec & " /c " & "msiexec /unregister")
RunWait(@ComSpec & " /c " & "msiexec /regserver")

; Check for prior versions of AVG
If FileExists(@ProgramFilesDir & "\Grisoft") Then
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce", "Restart Script", "REG_SZ", @ScriptFullPath & "/install")
    RunWait(@ScriptDir & "\avgremover.exe")
    Sleep (3000)
    ControlClick("Warning", "&Yes", 6)
ElseIf FileExists(@ProgramFilesDir & "\AVG\AVG8") Then
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce", "Restart Script", "REG_SZ", @ScriptFullPath & "/install")
    RunWait(@ScriptDir & "\avgremover.exe")
    Sleep (3000)
    ControlClick("Warning", "&Yes", 6)
Else
    If FileExists(@ProgramFilesDir & "\AVG\AVG9") Then
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce", "Restart Script", "REG_SZ", @ScriptFullPath & "/install")
        RunWait(@ScriptDir & "\avgremover.exe")
        Sleep (3000)
        ControlClick("Warning", "&Yes", 6)
    Else
    EndIf
    Exit
EndIf

; Install AVG 2011
Func installavg()
    RunWait(@ScriptDir & "\avgx86.exe")
    ; Remove Automatic Login Entries
    RegDelete("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName")
    RegDelete("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword")
    RegWrite("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon", "REG_SZ", 0)
EndFunc   ;==>installavg

If $cmdline[0] = "/install" Then installavg()
Link to comment
Share on other sites

Hi Cravin welcome here,

What does autoit Info Window say about your Warning message?

Is the controlID really "6" or maybe "button6" ?

btw: this line will never be true:

If $cmdline[0] = "/install" Then installavg()

look help file "$CmdLine[0] is number of parameters"

Link to comment
Share on other sites

Hey JFX, thanks for the reply.

Using the Window Information program, under the control tab, and right where it says ID, the number 6 is there. The title of the window is also listed as "Warning", and the button ID is 1, along with the text "&Yes", which I also tried. And thanks for pointing out the cmdline issue, I'll change it.

Either way I'm still clueless! Spent an hour or two reading the documentation and trying to debug the script last night to no avail.

Any other input would be appreciated. Does the If statement to check for older versions look okay/proper logic?

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...