Jump to content
Sign in to follow this  
RyanOlson

Problem with if then

Recommended Posts

RyanOlson

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

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
RyanOlson

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.

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
RyanOlson

I want it to continue say if the disclaimer window dosent show up but the warning window does I want it to continue on from there and so on

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.