Jump to content

Why my script is not stable?


lunj
 Share

Recommended Posts

Hi, I'm new to autoit. Developed a script to install/uninstall a program. It worked one day and stopped work the second day. Has anybody had this type of experience?

My script is

$sBase = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"

$iEval = 1

$sSearch = "Fiery"

While 1

$sUninst = ""

$sDisplay = ""

$sCurrent = RegEnumKey($sBase, $iEval)

If @Error Then ExitLoop

$sKey = $sBase & $sCurrent

$sDisplay = RegRead($sKey, "DisplayName")

If StringRegExp($sDisplay, "(?i).*" & $sSearch & ".*") Then

$sUninst = RegRead($sKey, "UninstallString")

If $sUninst Then

Run($sUninst)

WinwaitActive("Windows Installer")

WinActive("Windows Installer")

sleep(20)

ControlClick("Windows Installer", "Are you sure you want to uninstall this product?", "Yes")

EndIf

EndIf

$iEval += 1

WEnd

It worked one day, but stopped working the second day. Anything wrong with it? Your help is greatly appreciated. Thanks

Link to comment
Share on other sites

1) You havent specified what is wrong "stop working" is not sufficient

2) You should add some logic for waiting after ControlClick until each app is uninstalled

3) Add to your script some debug ConsoleWrite() to see what's going on and where it hangs

Sorry for not making it clear.

1. "Stop working" here means the pop up window "Windows Installer" can not be closed.---ControlClick("Fiery®VUE - InstallShield Wizard", "", "Ok") didn't work.

Thanks for the guidance! I was a perl developer. Now it's new to autoit. :idea:

Link to comment
Share on other sites

Also: please put your scripts in "autoit" tags, it makes it much easier to read.

$sBase = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" 
$iEval = 1 
$sSearch = "Fiery" 
While 1 
    $sUninst = "" 
    $sDisplay = "" 
    $sCurrent = RegEnumKey($sBase, $iEval) 
    If @Error Then ExitLoop 
    $sKey = $sBase & $sCurrent 
    $sDisplay = RegRead($sKey, "DisplayName") 
    If StringRegExp($sDisplay, "(?i).*" & $sSearch & ".*") Then 
        $sUninst = RegRead($sKey, "UninstallString") 
        If $sUninst Then 
            Run($sUninst) 
            WinwaitActive("Windows Installer")
            WinActive("Windows Installer")
                sleep(20)
            ControlClick("Windows Installer", "Are you sure you want to uninstall this product?", "Yes") 
                        
        EndIf 
    EndIf 
        $iEval += 1 
WEnd

#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

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