Jump to content

How to repeat my script until...


 Share

Recommended Posts

I need a new brain. I can't seen to figure out how to repeat my script until I press "No" to a messagebox question.

***** SCRIPT BEGINS *****

$host = InputBox("Hostname","Enter the destination hostname...")
$ping = Ping($host,250)

If $ping Then; also possible:  If @error = 0 Then ...
    Msgbox(0,"Status", $host & " is online, roundtrip was:" & $ping, 2)
Else
    Msgbox(0,"Status","An error occured with number: " & @error)
    Exit
EndIf

FileCopy("S:\EUSEASTNC\TEAM JAY\GNVL NOC\DynaText_4_1\5ess_oam.ini","\\" & $host & "\c$\Program Files\ltbooks\bin\",1)
Beep(500,200)
FileCopy("S:\EUSEASTNC\TEAM JAY\GNVL NOC\DynaText_4_1\5ESS Switch Documentation.lnk","\\" & $host & "\c$\Documents and settings\All users\Desktop\",1)
Beep(500,200)

MsgBox(262180,"Complete","Do you want to copy files to another host?",30)

***** SCRIPT ENDS *****

Can any one help? I would be greatful.... :)

Edited by MikroMan
Link to comment
Share on other sites

You can use a loop to call a function repeatedly until no is selected.

While 1
    PingHost()
    If MsgBox(262180,"Complete","Do you want to copy files to another host?",30) = 7 Then
        ExitLoop
    EndFunc
WEnd


Func PingHost()
    $host = InputBox("Hostname","Enter the destination hostname...")
    $ping = Ping($host,250)

    If $ping Then; also possible:  If @error = 0 Then ...
        Msgbox(0,"Status", $host & " is online, roundtrip was:" & $ping, 2)
    Else
        Msgbox(0,"Status","An error occured with number: " & @error)
        Exit
    EndIf

    FileCopy("S:\EUSEASTNC\TEAM JAY\GNVL NOC\DynaText_4_1\5ess_oam.ini","\\" & $host & "\c$\Program Files\ltbooks\bin\",1)
    Beep(500,200)
    FileCopy("S:\EUSEASTNC\TEAM JAY\GNVL NOC\DynaText_4_1\5ESS Switch Documentation.lnk","\\" & $host & "\c$\Documents and settings\All users\Desktop\",1)
    Beep(500,200)
EndFunc

:)

Link to comment
Share on other sites

You can use a loop to call a function repeatedly until no is selected.

While 1
    PingHost()
    If MsgBox(262180,"Complete","Do you want to copy files to another host?",30) = 7 Then
        ExitLoop
    EndFunc
WEnd
Func PingHost()
    $host = InputBox("Hostname","Enter the destination hostname...")
    $ping = Ping($host,250)

    If $ping Then; also possible:  If @error = 0 Then ...
        Msgbox(0,"Status", $host & " is online, roundtrip was:" & $ping, 2)
    Else
        Msgbox(0,"Status","An error occured with number: " & @error)
        Exit
    EndIf

    FileCopy("S:\EUSEASTNC\TEAM JAY\GNVL NOC\DynaText_4_1\5ess_oam.ini","\\" & $host & "\c$\Program Files\ltbooks\bin\",1)
    Beep(500,200)
    FileCopy("S:\EUSEASTNC\TEAM JAY\GNVL NOC\DynaText_4_1\5ESS Switch Documentation.lnk","\\" & $host & "\c$\Documents and settings\All users\Desktop\",1)
    Beep(500,200)
EndFunc

:D

You ROCK! Super Thanks!!!! :)

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