Question about .bat

Discussion in 'Software' started by Kzersatz, Feb 17, 2008.

  1. Kzersatz

    Kzersatz Private E-2

    yes... i know .bat lame

    but I'm simply attempting to write a batch file to auto-ping 3 servers, i have that part down but.... well the issue is hard to describe, let me post the code and ill work from there

    ---------------------------------------------------
    @echo off
    set [[/a [y]] [/p [variable=1]]string]
    set [[/a [n]] [/p [variable=2]]string]
    Title Ping
    REM "this batch was created for fun and to make it easyer to ping 3 servers whilst doing the morning checklist... have fun!


    echo Pinging tackleberry, typewriter and printers.
    pause

    ping -n 5 tackleberry
    pause

    ping -n 5 typewriter
    pause

    ping -n 5 printers
    pause
    cls
    echo Did all ping successfully? y/n
    set {y|n}
    pause
    --------------------------------------------

    Ok, i know the code sux but thats a different story

    what i need it to do is at the end prompt the Y or N so i can move on to further instructions once it pings properly
    and its not letting that happen... well more of not letting it happen because i dont know how to finish off the variable statement here

    "echo Did all ping successfully? y/n
    set {y|n}
    pause"
    any ideas??
    (note this is my first batch writeup and i am in NO WAY a programmer :cry )
     
  2. Wookie

    Wookie Sergeant Major

    Try this


    SET Success=
    SET /P Success=Type


    IF /I '%Success%'=='y' GOTO someline



    /I makes it case insensitive
     
  3. Kzersatz

    Kzersatz Private E-2

    so somthing like this?

    @echo off

    SET proper=y


    Title Ping
    REM "this batch was created for fun and to make it easyer to ping 3 servers whilst doing the morning checklist... have fun!


    echo Pinging tackleberry, typewriter, and printers.
    pause

    ping -n 5 www.google.com


    ping -n 5 www.yahoo.com


    ping -n 5 www.ogame.org

    pause
    cls

    echo Did all ping successfully? y/n
    SET /P Success=y/n -
    IF /I '%Success%'=='y' GOTO e1
    IF /I '%Success%'=='n' GOTO e2

    SET e1= echo Good
    pause
    :exit
    SET e2= echo Check your network connection than contact network support for further assistance at extension 7455
    pause
    :exit
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds