Jump to content

Program exits before it is finished


Recommended Posts

  • Moderators

As long as you've been here, you'd think you would have learned to post the actual code... there's no chk1() function to even test... but let's take the easy way out here, what is the error output that SciTe gives you?

Edit:

Case in point:

CODE
#include <GUIConstants.au3>
#include <Constants.au3>
GUICreate("Automatisch Installatie Script", @DesktopWidth, 30, 0, 0)
$ms = GUICtrlCreateProgress(1, 1, 988, 25)
$pt = GUICtrlCreateLabel("", 993, 11, 25)
WinSetOnTop("Automatisch Installatie Script", "", 1)
GUISetState(@SW_SHOW)
$main = GUICreate("Instellingen", 340, 300)

$button1 = GUICtrlCreateButton("Installeren", 260, 260)
GUICtrlSetTip($button1, "software installeren")
$program1 = "ZoneAlarm Security Suite"
$checkbox1 = GUICtrlCreateCheckbox($program1, 10, 10)
GUICtrlSetTip($checkbox1, "Zone Alarm Security Suite installeren")
$program2 = "NOD32"
$checkbox2 = GUICtrlCreateCheckbox($program2, 10, 30)
GUICtrlSetTip($checkbox2, "NOD32 installeren")
$program3 = "Hitman Pro"
$checkbox3 = GUICtrlCreateCheckbox($program3, 10, 50)
GUICtrlSetTip($checkbox3, "Hitman Pro installeren")
$program4 = "Avast Antivirus"
$checkbox4 = GUICtrlCreateCheckbox($program4, 10, 70)
GUICtrlSetTip($checkbox4, "Avast antivirus installeren")
$program5 = "Firefox"
$checkbox5 = GUICtrlCreateCheckbox($program5, 10, 90)
GUICtrlSetTip($checkbox5, "Firefox installeren")
$program6 = "Office 2003"
$checkbox6 = GUICtrlCreateCheckbox($program6, 10, 110)
GUICtrlSetTip($checkbox6, "Microsoft Office 2003 installeren")
$program7 = "WinRAR"
$checkbox7 = GUICtrlCreateCheckbox($program7, 160, 10)
GUICtrlSetTip($checkbox7, "WinRAR installeren")
$program8 = "Servicepack 2"
$checkbox8 = GUICtrlCreateCheckbox($program8, 160, 30)
GUICtrlSetTip($checkbox8, "Servicepack 2 installeren")
$program9 = "eMule"
$checkbox9 = GUICtrlCreateCheckbox($program9, 160, 50)
GUICtrlSetTip($checkbox9, "eMule installeren")
$program10 = "Windows Media Player 11"
$checkbox10 = GUICtrlCreateCheckbox($program10, 160, 70)
GUICtrlSetTip($checkbox10, "Windows Media Player 11 installeren")
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $button1
            ;chk1 ()
    EndSelect
WEnd
By commenting out your function there, it stays up fine. Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

The actual code is:

CODE DELETED

@Smoke_N

I didn't give the full code because there were legal lincense keys inside.

The previous version worked that was without the "Instellingen" Window

Edited by PcExpert
Link to comment
Share on other sites

The way you have you If Else Endif structure setup in the chkl function, only one task will be performed all all the others will be ignored. This is because you use if and then else. If the first If statement is true and $chkst1 = "1", then everything else that comes after the Else statement will not be executed because the first condition was true.

You might want to format your code. Use the SCITE editor on the download page and open an autoit script. Once a script is opened, press Ctrl+T and Tidy AutoIt Source will open and format your code correctly. The original will be placed in the same location in a folder titled backup.

If $chkst1 = "1" Then; If this is true, everything after the else will not be performed.
        Firewall()
    Else
        GUICtrlSetData($ms, 11.1)
        GUICtrlSetData($pt, 11.1)
        If $chkst2 = "1" Then; If this is even executed, it means that the first one wasn't even true.  If this is true, only the antivirus software installation is run.  Everything else will be ignored.
            virus()
        Else
            GUICtrlSetData($ms, 22.2)
            GUICtrlSetData($pt, 22.2)
            If $chkst3 = "1" Then
                hmp ()
            Else
                GUICtrlSetData($ms, 33.3)
                GUICtrlSetData($pt, 33.3)
                If $chkst4 = "1" Then
                    avast ()
                Else
                    GUICtrlSetData($ms, 44.4)
                    GUICtrlSetData($pt, 44.4)
                    If $chkst5 = "1" Then
                        fox ()
                    Else
                        GUICtrlSetData($ms, 55.5)
                        GUICtrlSetData($pt, 55.5)
                        If $chkst6 = "1" Then
                            office ()
                        Else
                            GUICtrlSetData($ms, 66.6)
                            GUICtrlSetData($pt, 66.6)
                            If $chkst7 = "1" Then
                                rar ()
                            Else
                                GUICtrlSetData($ms, 77.7)
                                GUICtrlSetData($pt, 77.7)
                                If $chkst8 = "1" Then
                                    sp2 ()
                                Else
                                    GUICtrlSetData($ms, 88.8)
                                    GUICtrlSetData($pt, 88.8)
                                    If $chkst9 = "1" Then
                                        p2p ()
                                    Else
                                        GUICtrlSetData($ms, 100)
                                        GUICtrlSetData($pt, 100)
                                        If $chkst10 = "1" Then
                                            reboot ()
                                        Else
                                            MsgBox(64, "Automatisch Installatie Script", "De installatie is voltooid. De computer wordt nu opnieuw opgestart. Dit programma is geprogrammeerd door: NAME", 10)
                                            Sleep(5000)
                                            Shutdown(2)
                                        EndIf
                                    EndIf
                                EndIf
                            EndIf
                        EndIf
                    EndIf
                EndIf
            EndIf
        EndIf
    EndIf

Do not use a huge If Else Endif structure like this. Give every function its own If Endif.

- The Kandie Man ;-)

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

The actual code is:

; ...<snip>

@Smoke_N

I didn't give the full code because there were legal lincense keys inside.

The previous version worked that was without the "Instellingen" Window

I don't see why you have two While loops here:

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit

        Case $msg = $button1
            chk1()

    EndSelect
WEnd

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Is this a logic error? The only way out of the first While loop is Exit on $GUI_EVENT_CLOSE, so you'll never reach the second one. Perhaps they are backwards and you intended the first one to ExitLoop and go to the second?

:)

P.S. Could you describe what you expect it to do once the boxes have been checked and the user clicks "Installeren". Because you chk1() function will only install one thing per click because of the way you stacked the If/Else statements. And the first thing chk1() does is close the main window. So once it installs one thing and returns to the message loop, the closed window triggers $GUI_EVENT_CLOSE and Exit.

:D

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I want it to work this way:

User runs the program

User defines what he wants to install

Then the User clicks on the 'installeren' button to install the selected software

Once the 'installeren' button is clicked the 'instellingen' GUI dissapears and the installer will run

On each installation that is complete or not selected the progressbar will increment with 11.1 %

Edited by PcExpert
Link to comment
Share on other sites

I looked over ur code and tried to fix it, but i cant test it so there could be some mistakes:

#include <GUIConstants.au3>
$main = GUICreate("Instellingen", 340, 300)
$button1 = GUICtrlCreateButton("Installeren", 260, 260)
GUICtrlSetTip($button1, "software installeren")
$program1 = "ZoneAlarm Security Suite"
$checkbox1 = GUICtrlCreateCheckbox($program1, 10, 10)
GUICtrlSetTip ($checkbox1, "Zone Alarm Security Suite installeren")
$program2 = "NOD32"
$checkbox2 = GUICtrlCreateCheckbox($program2, 10, 30)
GUICtrlSetTip ($checkbox2, "NOD32 installeren")
$program3 = "Hitman Pro"
$checkbox3 = GUICtrlCreateCheckbox($program3, 10, 50)
GUICtrlSetTip ($checkbox3, "Hitman Pro installeren")
$program4 = "Avast Antivirus"
$checkbox4 = GUICtrlCreateCheckbox($program4, 10, 70)
GUICtrlSetTip ($checkbox4, "Avast antivirus installeren")
$program5 = "Firefox"
$checkbox5 = GUICtrlCreateCheckbox($program5, 10, 90)
GUICtrlSetTip ($checkbox5, "Firefox installeren")
$program6 = "Office 2003"
$checkbox6 = GUICtrlCreateCheckbox($program6, 10, 110)
GUICtrlSetTip ($checkbox6, "Microsoft Office 2003 installeren")
$program7 = "WinRAR"
$checkbox7 = GUICtrlCreateCheckbox($program7, 160, 10)
GUICtrlSetTip ($checkbox7, "WinRAR installeren")
$program8 = "Servicepack 2"
$checkbox8 = GUICtrlCreateCheckbox($program8, 160, 30)
GUICtrlSetTip ($checkbox8, "Servicepack 2 installeren")
$program9 = "eMule"
$checkbox9 = GUICtrlCreateCheckbox($program9, 160, 50)
GUICtrlSetTip ($checkbox9, "eMule installeren")
$program10 = "Windows Media Player 11"
$checkbox10 = GUICtrlCreateCheckbox($program10, 160, 70)
GUICtrlSetTip ($checkbox10, "Windows Media Player 11 installeren")
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
exit

Case $msg = $button1
GUICreate("Automatisch Installatie Script", @DesktopWidth, 30, 0, 0)
$ms = GUICtrlCreateProgress(1, 1, 988, 25)
$pt = GUICtrlCreateLabel("", 993, 11, 25)
WinSetOnTop("Automatisch Installatie Script", "", 1)
GUISetState(@SW_SHOW)
chk1()

endselect
wend
;chk1---------------------------
Func chk1()
GUISetState(@SW_HIDE, $main)
$chkst1 = GUICtrlRead($checkbox1)
$chkst2 = GUICtrlRead($checkbox2)
$chkst3 = GUICtrlRead($checkbox3)
$chkst4 = GUICtrlRead($checkbox4)
$chkst5 = GUICtrlRead($checkbox5)
$chkst6 = GUICtrlRead($checkbox6)
$chkst7 = GUICtrlRead($checkbox7)
$chkst8 = GUICtrlRead($checkbox8)
$chkst9 = GUICtrlRead($checkbox9)
$chkst10 = GUICtrlRead($checkbox10)

if $chkst1 = $GUI_CHECKED then
firewall()
Else
GUICtrlSetData($ms, 11.1)
GUICtrlSetData($pt, 11.1)
EndIf
if $chkst2 = $GUI_CHECKED then
virus()
Else
GUICtrlSetData($ms, 22.2)
GUICtrlSetData($pt, 22.2)
EndIf
if $chkst3 = $GUI_CHECKED then
hmp()
Else
GUICtrlSetData($ms, 33.3)
GUICtrlSetData($pt, 33.3) 
EndIf
if $chkst4 = $GUI_CHECKED then
avast()
Else
GUICtrlSetData($ms, 44.4)
GUICtrlSetData($pt, 44.4) 
EndIf
if $chkst5 = $GUI_CHECKED then
fox()
Else
GUICtrlSetData($ms, 55.5)
GUICtrlSetData($pt, 55.5)  
EndIf
if $chkst6 = $GUI_CHECKED then
office()
Else
GUICtrlSetData($ms, 66.6)
GUICtrlSetData($pt, 66.6) 
EndIf
if $chkst7 = $GUI_CHECKED then
rar()
Else
GUICtrlSetData($ms, 77.7)
GUICtrlSetData($pt, 77.7) 
EndIf
if $chkst8 = $GUI_CHECKED then
sp2()
Else
GUICtrlSetData($ms, 88.8)
GUICtrlSetData($pt, 88.8) 
EndIf
if $chkst9 = $GUI_CHECKED then
p2p()
Else
GUICtrlSetData($ms, 100)
GUICtrlSetData($pt, 100)
EndIf
if $chkst10 = $GUI_CHECKED then
reboot()
Else
MsgBox(64, "Automatisch Installatie Script", "De installatie is voltooid. De computer wordt nu opnieuw opgestart. Dit programma is geprogrammeerd door: NAME", 10)
Sleep(5000)
Shutdown(2)
EndIf
EndFunc
;Functions---------------------------
 Func Firewall()
 Run("Zone Alarm Security Suite\setup.exe")
 WinWaitActive("ZoneAlarm Security Suite Installation", "It is strongly recommended that you exit all Windows programs before running this Setup program.")
 Send("{ENTER}")
 WinWaitActive("ZoneAlarm Registration", "&Inform me about important product and security news.")
 Send("{TAB}")
 Send("EMAILHERE")
 Send("{TAB 2}")
 Send("{SPACE}")
 Send("{ENTER}")
 WinWaitActive("ZoneAlarm Security Suite Installation", "END USER LICENSE AGREEMENT")
 Send("{TAB 3}")
 Send("{SPACE}")
 Send("{TAB}")
 Send("{SPACE}")
 WinWaitActive("ZoneAlarm Registration Survey", "Choose one:")
 Send("{DOWN 5}")
 Send("{TAB}")
 Send("{DOWN 2}")
 Send("{TAB}")
 Send("{DOWN 3}")
 Send("{TAB}")
 Send("{DOWN 7}")
 Send("{ENTER}")
 WinWaitActive("ZoneAlarm Security Suite Setup", "Installation is complete. Do you want to start ZoneAlarm Security Suite now?")
 Send("{ENTER}")
 WinWaitActive("Configuration Wizard", "&Maximum")
 Send("{ENTER}")
 WinWaitActive("Configuration Wizard", "&Participate in DefenseNet")
 Send("{DOWN}")
 Send("{ENTER}")
 WinWaitActive("Configuration Wizard", "Yes - &Enable Anti-virus protection")
 Send("{DOWN}")
 Send("{ENTER}")
 WinWaitActive("Configuration Wizard", "&Scan my computer (recommended)")
 Send("{DOWN}")
 Send("{ENTER}")
 WinWaitActive("Configuration Wizard", "&Finish")
 Send("{ENTER}")
 GUICtrlSetData($ms, 11.1)
 GUICtrlSetData($pt, 11.1)
EndFunc

Func virus()
 Sleep(2500)
 Run("NOD32\NOD32.exe")
 WinWaitActive("NOD32NT", "&Extract to")
 Send("{ENTER}")
 WinWaitActive("Testversie", "Testversie")
 Send("{ENTER}")
 WinWaitActive("Setup Wizard", "Setup Wizard")
 Send("{ENTER}")
 WinWaitActive("Eindgebruikers Software Licentie Overeenkomst", "Eindgebruikers Software Licentie Overeenkomst")
 Send("{TAB 3}")
 Send("{LEFT}")
 Send("{ENTER}")
 WinWaitActive("Internet connectie", "Internet connectie")
 Send("{ENTER}")
 WinWaitActive("ThreatSense.Net Vroege Waarschuwingssysteem", "ThreatSense.Net Vroege Waarschuwingssysteem")
 Send("{ENTER}")
 WinWaitActive("Antivirus systeem scanner - AMON", "Antivirus systeem scanner - AMON")
 Send("{ENTER}")
 WinWaitActive("Verzamelen van de Setup parameters afgerond", "Verzamelen van de Setup parameters afgerond")
 Send("{ENTER}")
 WinWaitActive("Installatie afgerond", "Installatie afgerond")
 Send("{RIGHT}")
 Send("{ENTER}")
 GUICtrlSetData($ms, 22.2)
 GUICtrlSetData($pt, 22.2)
 EndFunc
 
  Func hmp()
 Sleep(2500)
 Run("HITMAN PRO\setup.exe")
 WinWaitActive("Taalkeuze voor Setup", "Selecteer de taal welke Setup gebruikt tijdens de installatie:")
 Send("{ENTER}")
 WinWaitActive("Setup - Hitman Pro 2.6", "Welkom bij het installatieprogramma van Hitman Pro 2.6.")
 Send("{ENTER}")
 WinWaitActive("Setup - Hitman Pro 2.6", "Licentieovereenkomst")
 Send("{TAB}")
 Send("{UP}")
 Send("{ENTER}")
 WinWaitActive("Setup - Hitman Pro 2.6", "Kies de doelmap")
 Send("{ENTER}")
 WinWaitActive("Setup - Hitman Pro 2.6", "Selecteer extra taken")
 Send("{ENTER}")
 WinWaitActive("Setup - Hitman Pro 2.6", "Het voorbereiden van de installatie is gereed")
 Send("{ENTER}")
 WinWaitActive("Setup - Hitman Pro 2.6", "Setup heeft het installeren van Hitman Pro 2.6 op deze computer voltooid.")
 Send("{SPACE}")
 Send("{ENTER}")
 GUICtrlSetData($ms, 33.3)
 GUICtrlSetData($pt, 33.3)
 EndFunc
 
 Func avast()
 sleep(2500)
 Run("Avast\setupengpro.exe")
    WinWaitActive("avast! Antivirus Setup", "Welcome to the avast! Setup program. This program will install avast! on your computer.")
    Send("{ENTER}")
 WinWaitActive("avast! Antivirus Setup", "Read me")
 Send("{ENTER}")
 WinWaitActive("avast! Antivirus Setup", "I &agree")
 Send("{LEFT}")
 Send("{ENTER}")
 WinWaitActive("avast! Antivirus Setup", "&Enter the destination directory")
 Send("{ENTER}")
 WinWaitActive("avast! Antivirus Setup", "Configuration")
 Send("{ENTER}")
 WinWaitActive("avast! Antivirus Setup", "Installation information")
 Send("{ENTER}")
 WinWaitActive("Question", "&Ja")
 Send("{RIGHT}")
 Send("{ENTER}")
 WinWaitActive("avast! Antivirus Setup", "Setup finished")
 Send("{TAB}")
 Send("{DOWN}")
 Send("{TAB}")
 Send("{ENTER}")
 GUICtrlSetData($ms, 44.4)
 GUICtrlSetData($pt, 44.4)
 EndFunc
 
 Func fox()
 sleep(2500)
 Run("FIREFOX\Firefox Setup.exe")
 WinWaitActive("Installatie Firefox", "Welkom bij Mozilla Firefox")
 Send("{ENTER}")
 WinWaitActive("Licentieovereenkomst", "Ik accepteer de licentieovereenkomst NIE&T")
 Send("{UP}")
 Send("{ENTER}")
 WinWaitActive("Installatietype", "De browser zal worden geïnstalleerd met de meest gebruikelijke onderdelen.")
 Send("{ENTER}")
 WinWaitActive("Onderdelen selecteren", "Het installatieprogramma zal nu de volgende onderdelen installeren:")
 Send("{ENTER}")
 WinWaitActive("Installatie voltooid", "Installatie voltooid")
 Send("{SPACE}")
 Send("{ENTER}")
 GUICtrlSetData($ms, 55.5)
 GUICtrlSetData($pt, 55.5)
 EndFunc
 
 Func office()
 sleep(2500)
 Run("MICROSOFT OFFICE 2003\setup.exe")
 WinWaitActive("Microsoft Office 2003 Setup", "Geef in de onderstaande vakken de productcode (Product Key) van 25 tekens op. U vindt deze code op de sticker op de achterzijde van het cd-doosje of op het Certificate of Authenticity (Certificaat van Echtheid).")
 Send("LICENSEKEYHERE")
 Send("{ENTER}")
 WinWaitActive("Microsoft Office 2003 Setup", "&Gebruikersnaam:")
 Send("{TAB}")
 Send("MK")
 Send("{ENTER}")
 WinWaitActive("Microsoft Office 2003 Setup", "U moet de voorwaarden in de gebruiksrechtovereenkomst accepteren voordat u kunt doorgaan met de installatie van Office. Schakel het onderstaande selectievakje in om de overeenkomst te accepteren.")
 Send("{SPACE}")
 Send("{ENTER}")
 WinWaitActive("Microsoft Office 2003 Setup", "&Standaardinstallatie")
 Send("{DOWN}")
 Send("{ENTER}")
 WinWaitActive("Microsoft Office 2003 Setup", "&Installeren")
 Send("{ENTER}")
 WinWaitActive("Microsoft Office 2003 Setup", "Microsoft Office 2003 Setup is voltooid.")
 Send("{ENTER}")
 GUICtrlSetData($ms, 66.6)
 GUICtrlSetData($pt, 66.6)
 EndFunc

 Func rar()
 sleep(2500)
 Run("WINRAR\winrarnl.exe")
 WinWaitActive("WinRAR 3.51", "TITLE_BMP")
 Send("{ENTER}")
 WinWaitActive("Installatie WinRAR", "WinRAR associëren met")
 Send("{ENTER}")
 WinWaitActive("Installatie WinRAR", "WinRAR is succesvol geïnstalleerd in:")
 Send("{ENTER}")
 WinWaitActive("WinRAR")
 WinClose("WinRAR")
 GUICtrlSetData($ms, 77.7)
 GUICtrlSetData($pt, 77.7)
 EndFunc
 
 Func sp2()
 sleep(2500)
 Run("WINDOWS XP SP 2\XPSP2.exe")
 WinWaitActive("Wizard Setup van Windows XP Service Pack 2", "De wizard Setup van ")
 Send("{ENTER}")
 Send("{TAB 2}")
 Send("{SPACE}")
 Send("{ENTER}")
 WinWaitActive("Wizard Setup van Windows XP Service Pack 2", "Setup maakt een back-up van systeembestanden, zodat u het servicepack later kunt verwijderen, mocht dat nodig zijn. Klik op Bladeren als u een locatie voor deze back-upbestanden wilt selecteren, of klik op Volgende als u de onderstaande locatie wilt gebruiken.")
 Send("{ENTER}")
 WinWaitActive("Wizard Setup van Windows XP Service Pack 2", "&Niet opnieuw opstarten")
 Send("{SPACE}")
 Send("{ENTER}")
 GUICtrlSetData($ms, 88.8)
 GUICtrlSetData($pt, 88.8)
 EndFunc
 
 Func p2p()
 DirCopy("\INSTALL\eMule", "C:\Program Files\eMule", 1)
 GUICtrlSetData($ms, 100)
 GUICtrlSetData($pt, 100)
 EndFunc

 Func reboot()
 DirCopy(@ScriptDir & "\WMP 11", "C:\INSTTEMP\WMP\")
 FileCopy("install2.exe", "C:\Documents and Settings\All Users\Menu Start\Programma's\Opstarten\install2.exe")
 MsgBox(64, "Automatisch Installatie Script", "De installatie is voltooid. De computer wordt nu opnieuw opgestart. Dit programma is geprogrammeerd door: Maarten Keyman", 10)
 Sleep(5000)
 Shutdown(2)
EndFunc
Edited by poisonkiller
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...