Jump to content

Problem with if then


Recommended Posts

I am trying to write a simple installer for combo fix this is where I get stuck I dont want to have to wait for hours on end for it to come up

MsgBox(0, "Downloading Files", "Downloading files now.  This may take several minutes to complete.")
DirCreate(EnvGet("homedir") & "\blah\")
DirCreate(EnvGet("homedir") & "\blah\temp\")
InetGet("http://download.bleepingcomputer.com/sUBs/ComboFix.exe", @HomeDrive & "\PC Repair Centers\temp\CF101abc234.exe")
MsgBox(0, "Downloading Files", "All files have been downloaded successfully.")
Run(@HomeDrive & "\blah\temp\CF101abc234.exe")

if WinWaitActive("DISCLAIMER OF WARRANTY ON SOFTWARE." , "&Yes",6000000000000000)Then
send("!y")

elseif WinWaitActive("Warning !!", "OK", 600000000000000000 ) Then
Send("{space}")
WinWaitActive("Warning !!", "OK" , 6000000000000)
Send("{space}")

else

If WinWaitActive("Microsoft Windows Recovery Console", "&yes", 600000000000000000 ) Then Send("!y")
WinWaitActive("Installing the Recovery Console", "OK", 60000000000000000000 )
Send("{space}")
WinWaitActive("Windows XP Professional SP2 CD Boot Floppies" , "&Yes" , 600000000000000000000 )
Send("!y")
WinWaitActive("Info" , "&Yes" , 60000000000000000000000)
Send("!y")

Else
if WinWaitActive("rootkit", "OK", 600000000) then
Send("{space}")
Else
WinExists(".","")
EndIf
Link to comment
Share on other sites

Why would you have to wait hours? WinWaitActive() timeout is an INT32 value, so your value is invalid anyway, but regardless of its value the function returns when the specified windows becomes active without waiting for the rest of the timeout value.

You should probably use just WinWait() vice WinWaitActive(), and ControlSend() vice Send() to make it more reliable.

Are you running this under a scheduled task or locked desktop? Because no window is ever active under those circumstances.

:mellow:

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 don't really care about the time outs the main issue is if the one window does not come up it never moves on to the next part of the code so if the disclaimer window does not come up for some reason it stops there unless I set a time out.

Link to comment
Share on other sites

So you don't care about timeouts, but want to properly handle timeouts... wait, what?

:P

You can add an ELSE statement to your wait functions to handle error conditions:

; 2min timeout
If WinWait("WinTitle", "WinTxt", 120000) Then
     ; What to do when window appears
     ControlSend("WinTitle", "WinTxt", "", "!n") ; Next
Else
     ; What to do when window times out

EndIf

You have to decide what to do if the window times out. Is it a critical error or not? Show the user an error message? Logging? Continue script or exit?

You have to decide and code it in there.

:mellow:

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

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