Sign in to follow this  
Followers 0
MikroMan

How to repeat my script until...

3 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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

:)

Share this post


Link to post
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!!!! :)

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  
Followers 0