Jump to content

Script only Works on Some Computers

Recommended Posts

Hi, everybody. I've gotten my script to work without a single problem on two Windows 7 Enterprise x64 machines. The script puts the PC into a clean boot, installs Kaspersky Workstation 6.0, reboots the machine, updates it using local files, reboots again, and does the remaining updates from the internet after connecting to a specific wireless connection. I've spent about three weeks putting it together, so I'm not ready to give up on it.

When I try it on other, slower Windows 7 Pro x86 machines (using the x86 build), the buttons in Kaspersky's main window are seemingly resisting automation, even on a Clean Boot installation. I've tried everything I can think of to debug this, including:

*Using ControlSend instead of ControlClick

*Checking return status of the commands (always successful)

*Using WinActivate immediately before command

*Using _WinAPI_WaitForInputIdle (returns 4294967295)

*Using plain-old MouseClick events

*Inserting Sleep statements

*Pressing the buttons myself in an effort to advance the script (fumbles and fails when in Kaspersky windows)

*Manually checking w/ AutoIt Window Info that the handles for the window and button are correct (they are)

*MsgBox'ing @error after every command in the general vicinity (all return 0)

Right now, I really just don't know what's left to try aside from direct Windows API calls, which I know very little about. Do I need certain .NET components for these commands to be interpreted properly? I know that Kaspersky has some odd custom controls going on, but why would script behavior deviate from one PC to another? Here are the Opts I'm running:

Opt("WinTitleMatchMode", 2)
Edited by KongMD
Link to post
Share on other sites

Does the software have a silent install option so you don't have to click anything just run it?

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

Link to post
Share on other sites
  • Moderators

Hi, KongMD. As BrewMan suggested, a silent install should help you greatly. Kaspersky includes a large number of switches you can use with a silent install, everything from where you want to install the product to firing off a scan of the computer upon completion. Try the link below for a list of available switches.


"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites

I appreciate the sentiment, and knew about the silent switches from the get-go. The value of the script, to me, is being able to automate the whole setup process, including the quick scan temporary disabling (to avoid a bug) and updating the software. Also, updating ~280MB of tiny database files from the hard disk is significantly faster than doing a web update.

What's the proper way to use _WinAPI_WaitForInputIdle? The msgbox below outputted the following: 4294967295, instead of 1 or 0:

;Disable Quick Scan temporarily, if not disabled already
   SetStatus("Disabling Quick Scan (temporarily)")
   WinWaitActivate("Kaspersky Anti-Virus 6.0 for Windows Workstations","")
   $mainWin = WinGetHandle("Kaspersky Anti-Virus 6.0 for Windows Workstations")
   $settingsBtn = ControlGetHandle($mainWin, "", "AVP.Button1")
   $inputIdle = _WinAPI_WaitForInputIdle($mainWin)
   MsgBox(64, "inputIdle return", $inputIdle)
Edited by KongMD
Link to post
Share on other sites

After reading I'm starting to wonder if the input blocking is UAC-related. My script disables UAC, but it launches an executable (x86 or x64, depending on architecture) after copying the folders to the user's Temp directory. That executable should have the same UAC "fix" code as the original .exe, though. Here's what I have at the beginning of each script:

; UAC fix

I tried putting the code that disables UAC in the registry before the code launching the second executable, but that didn't change anything. I'm coming back to the idea that the problem in my code is that the commands are being sent too soon (see above post). Suggestions or comments would be great!

Edited by KongMD
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...