Jump to content

Recommended Posts

Posted

I need "goto" to skip a part of my script like below.

How can I solve this with V3?

; Check if MS Visual C++ 6.0 is uninstalled

$STEIN = RegRead ( "HKEY_LOCAL_MACHINE\SOFTWARE\PEACY\CSISM_34", "STEIN" )

MsgBox(0, "Test", $STEIN)

If $STEIN = "Uninstalled" then Goto, Install

EndIf

#comments-start

Uninstall Visual Studio C++ 6.0 Standard Edition

#comments-end

If FileExists ("C:\Program Files\Microsoft Visual Studio\VC98\Setup\1033\Setup.exe") Then

Run ("C:\Program Files\Microsoft Visual Studio\VC98\Setup\1033\Setup.exe /UA")

RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\PEACY\CSISM_34", "STEIN", "REG_SZ", "Uninstalled" )

EndIf

WinWaitActive ("Visual C++ 6.0 Standard Setup", "Visual C++ 6.0 Standard - Restart Windows")

Send("{TAB}")

Sleep(2000)

Send("{Enter}")

Sleep(2000)

WinWaitActive ("Visual C++ 6.0 Standard Setup", "Visual C++ 6.0 Standard - Restart Failed")

Sleep(2000)

Send("{Enter}")

Sleep(2000)

WinWaitActive ("Visual C++ 6.0 Standard Setup", "Visual C++ 6.0 Standard Setup")

Sleep(2000)

Send("{Enter}")

Sleep(2000)

DirRemove ("C:\Program Files\Microsoft Visual Studio", 1)

;Install:

Posted

; Check if MS Visual C++ 6.0 is uninstalled
$STEIN = RegRead ( "HKEY_LOCAL_MACHINE\SOFTWARE\PEACY\CSISM_34", "STEIN" )
MsgBox(0, "Test", $STEIN)
If $STEIN = "Uninstalled" Then
  ;Install:
Else
   #comments-start
   Uninstall Visual Studio C++ 6.0 Standard Edition
   #comments-end
   
   If FileExists ("C:\Program Files\Microsoft Visual Studio\VC98\Setup\1033\Setup.exe") Then
   Run ("C:\Program Files\Microsoft Visual Studio\VC98\Setup\1033\Setup.exe /UA")
   RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\PEACY\CSISM_34", "STEIN", "REG_SZ", "Uninstalled" )
   EndIf
   
   WinWaitActive ("Visual C++ 6.0 Standard Setup", "Visual C++ 6.0 Standard - Restart Windows")
   Send("{TAB}")
   Sleep(2000)
   Send("{Enter}")
   Sleep(2000)
   WinWaitActive ("Visual C++ 6.0 Standard Setup", "Visual C++ 6.0 Standard - Restart Failed")
   Sleep(2000)
   Send("{Enter}")
   Sleep(2000)
   WinWaitActive ("Visual C++ 6.0 Standard Setup", "Visual C++ 6.0 Standard Setup")
   Sleep(2000)
   Send("{Enter}")
   Sleep(2000)
   
   DirRemove ("C:\Program Files\Microsoft Visual Studio", 1)
EndIf

Posted

Define functions then call them.

Func Install ()

your code here

end func

Func donothing()

exit

end func

If statment then

Install()

else

donothing()

endif

CheersNobby

Posted

A different example to fix your goto code:

; old code
$x=1
:start
msgbox(1,"","hi")
$x=$x+1
if $x>10 then 
goto :start
endif

; new code
$x=1
do
msgbox(1,$x,"hi")
$x=$x+1
until $x>10

AutoIt3, the MACGYVER Pocket Knife for computers.

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
×
×
  • Create New...