Jump to content

Retrun Value from Message box


Recommended Posts

Ok I need a little help here to get the returned value from a message box.

I am trying to put up an info screen prior to a scripted installation. If they click ok I want the script to proceed if they click cancel i want the script to end.

Everything works except the message box

Thanks in advance

MsgBox(65, "Warning", "Please close all applications before proceeding and only run this application from your local drive.")
 $value = Msgbox
If $value = "1" Then begincheck()
Else End()
    EndIf



Func begincheck()
If FileExists("C:\Program Files\Citrix\ICA Client\Wfica32.EXE") Then
$version = FileGetVersion("C:\Program Files\Citrix\ICA Client\Wfica32.EXE")
If $version = "9.100.36280" Then 
    Upgradeto10()
ElseIf $version = "9.0.32649.0" Then 
    Upgradeto10()
ElseIf $version = "9.150.39151" Then
    Upgradeto10()
ElseIf $version = "9.200.44376" Then 
    Upgradeto10()
ElseIf $version = "9.230.50211" Then
    Upgradeto10()
ElseIf $version = "9.237.53063" Then
    Upgradeto10()
Else
Install9to10()
EndIf
EndIf
EndFunc;==>begincheck
Func Install9to10()
ProgressOn("Progress Meter", "Installation In Progress, Please Wait", "0 percent")
For $i = 1 to 49 step 1
    sleep(1000)
    ProgressSet( $i, $i & " percent")
Next
Run("msiexec /i 9_0.msi")
WinWaitActive("Installer Information")
Send("!n")
ProgressSet(50 , "Almost Done", "Installation In Progress, Please Wait")
For $i = 50 to 99 step 1
    sleep(1000)
 ProgressSet( $i, $i & " percent")
Next
Run("msiexec /i 10_0.msi")
ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()
EndFunc;==>Install9to10
Func Upgradeto10()
ProgressOn("Progress Meter", "Installation In Progress, Please Wait", "0 percent")
Run("msiexec /i 10_0.msi")
For $i = 1 to 80 step 1
    sleep(1000)
    ProgressSet( $i, $i & " percent")
Next
EndFunc;==>Upgradeto10
Func End()
    EndFunc;==>End
Link to comment
Share on other sites

you were very close

$value = MsgBox(65, "Warning", "Please close all applications before proceeding and only run this application from your local drive.")
If $value = "1"  Then
    begincheck()
Else
    End()
EndIf

Func begincheck()
    If FileExists("C:\Program Files\Citrix\ICA Client\Wfica32.EXE") Then
        $version = FileGetVersion("C:\Program Files\Citrix\ICA Client\Wfica32.EXE")
        If $version = "9.100.36280"  Then
            Upgradeto10()
        ElseIf $version = "9.0.32649.0"  Then
            Upgradeto10()
        ElseIf $version = "9.150.39151"  Then
            Upgradeto10()
        ElseIf $version = "9.200.44376"  Then
            Upgradeto10()
        ElseIf $version = "9.230.50211"  Then
            Upgradeto10()
        ElseIf $version = "9.237.53063"  Then
            Upgradeto10()
        Else
            Install9to10()
        EndIf
    EndIf
EndFunc   ;==>begincheck
Func Install9to10()
    ProgressOn("Progress Meter", "Installation In Progress, Please Wait", "0 percent")
    For $i = 1 To 49 Step 1
        Sleep(1000)
        ProgressSet($i, $i & " percent")
    Next
    Run("msiexec /i 9_0.msi")
    WinWaitActive("Installer Information")
    Send("!n")
    ProgressSet(50, "Almost Done", "Installation In Progress, Please Wait")
    For $i = 50 To 99 Step 1
        Sleep(1000)
        ProgressSet($i, $i & " percent")
    Next
    Run("msiexec /i 10_0.msi")
    ProgressSet(100, "Done", "Complete")
    Sleep(500)
    ProgressOff()
EndFunc   ;==>Install9to10
Func Upgradeto10()
    ProgressOn("Progress Meter", "Installation In Progress, Please Wait", "0 percent")
    Run("msiexec /i 10_0.msi")
    For $i = 1 To 80 Step 1
        Sleep(1000)
        ProgressSet($i, $i & " percent")
    Next
EndFunc   ;==>Upgradeto10
Func End()
EndFunc   ;==>End
Link to comment
Share on other sites

$value = MsgBox(65, "Warning", "Please close all applications before proceeding and only run this application from your local drive.")

If $value = "1" Then begincheck()

Else End()

EndIf

Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Link to comment
Share on other sites

$value = MsgBox(65, "Warning", "Please close all applications before proceeding and only run this application from your local drive.")

If $value = "1" Then begincheck()

Else End()

EndIf

That will NOT work

"If $value = 1 Then begincheck()" <--- this line will not take as 'Else' or an 'EndIf' because it is complete as it sits... in other words

This:

If $value = 1 Then begincheck() <--- because this is all on one line, and there are commands after 'Then', there will be no EndIf or Else accepted... the EndIf in this case is just the end of this line

Is the same as this:

If $value = 1 Then

begincheck()

EndIf

Does that clear things up?

Also, please test your code before trying to assist people.

Link to comment
Share on other sites

Func begincheck()
    If FileExists("C:\Program Files\Citrix\ICA Client\Wfica32.EXE") Then
        $version = FileGetVersion("C:\Program Files\Citrix\ICA Client\Wfica32.EXE")
        If $version = "9.100.36280"  Then
            Upgradeto10()
        ElseIf $version = "9.0.32649.0"  Then
            Upgradeto10()
        ElseIf $version = "9.150.39151"  Then
            Upgradeto10()
        ElseIf $version = "9.200.44376"  Then
            Upgradeto10()
        ElseIf $version = "9.230.50211"  Then
            Upgradeto10()
        ElseIf $version = "9.237.53063"  Then
            Upgradeto10()
        Else
            Install9to10()
        EndIf
    EndIf
EndFunc  ;==>begincheck

Using C:\Program Files\ is not a great idea if this is supposed to run on systems other than your own

Use the @ProgramFilesDir macro instead. Better yet, I think that value is stored in the registry so read it from there.

The best place to start looking is HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\

The Whole function can be shortened with

$vChk = "9.100.36280|9.0.32649.0|9.150.39151|9.200.44376|9.230.50211|9.237.53063|"
If StringInStr($vChk, $Version & "|") Then
   Upgradeto10()
Else
   Install9to10()
EndIf

If all of the versions that require Install9to10() start with something other than 9 then use.

Switch StringLeft($Version, 1)
   Case 9
      Upgradeto10()
   Case Else
      Install9to10()
EndSwitch

Just a couple of alternatives.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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