Sign in to follow this  
Followers 0
PDowning

Infinite loop ... do not want :-)

10 posts in this topic

While the other guys are figuring out my other thread, here's a new one. I seem to have created an infinite loop, something I haven't done since high school using Assembly, now that required talent o:) .   Here is the code:

#include <GUIConstantsEX.au3>
#include <EditConstants.au3>


GUICreate('Application Launcher',400,100) ;Create 'Please Wait' window
GUISetState(@SW_SHOW)
$wasabi=GUICtrlCreateLabel ('Installing Kaspersky Anti-Virus - Please Wait',95,45)

$KASProcess = "setup.exe"
While 1
    If Not ProcessExists($KASProcess) Then

        If FileExists("C:\Program Files\Kaspersky Lab\Kaspersky Endpoint Security 10 for Windows\avp.exe") Then
            MsgBox(0, "kas", "installed")
            ExitLoop
        Else
            ;MsgBox(0, "Installing Kaspersky Anti-Virus", " Please wait while KAS Installs ..... ")
            RunWait("\\tar-fs01\KLSHARE\PkgInst\NetAgent_10.0.3361_KES_10.1.0.867\setup.exe")
        EndIf
    EndIf
WEnd

Basically, check to see if the process "setup.exe" is running, if not see if the program is installed, if not, install it. If it is installed exit the loop(that part works if it's installed), otherwise install it before continuing the script.  This script will do this for several programs, not just this AV program.  Yet somehow I managed to get it to install itself over and over :censored: .   Failed logic again?

Share this post


Link to post
Share on other sites



I don't see anything wrong with this loop or the logic. 

Cosmetically, I'd use GuiSetState(@SW_SHOW) inside your Else statement instead of the custom msgbox.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

The only thing that strikes me is if your path to the avp.exe is incorrect.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Or, you are looking for the wrong dir...try using @ProgramFilesDir instead of C:program files


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Then why does it loop. When it gets to the end, the process setup.exe is no longer valid, so it SHOULD end. But it ends the If Not section, not the While 1 section. But even then, when it loops back around, doesn't see the process running, it checks to see if the file exists to show that it's been installed, and SHOULD exit the while loop. But it's not.

Share this post


Link to post
Share on other sites

So you need to do some error checking - put in a couple of MsgBoxes to figure out where your logic is failing.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Yep, so either the file does not exist after the instal, or the installer is not there, or the installer is present, and no action is being performed on it...you are not passing silent install switches.

Do logging to see what's up...get the return of runwait, and log it...do a file check on the installer prior to running it...maybe the drive is not visible to the station?  Do some checking on that also.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

If the setup program doesn't exist, then the setup will never be run, and so the loop will continue. Likewise if the path to the final file is incorrect then it will keep trying to run the setup.

There's a few things you should do:

  * Check whether the setup actually runs

  * Make sure the setup doesn't run more than once.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

added a few strategically placed msgbox's and we'll see where it gets me

Edit: spelling errors

Edited by PDowning

Share this post


Link to post
Share on other sites

got it sorted out.   Turns out the install was failling when running it from the server for some reason. Copied the file to c: and ran from there and it works like a charm.

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