locked
"For" statement in batch files RRS feed

  • Question

  • I have a batch file i am working on and having some problems with the “for” command.

     

    Here is a small piece of it.

     

    Rem start

    for /f %%a in (pclist.txt) do ping -n 1 %%a | find /i "reply from"

    goto ReturnCode_%ERRORLEVEL%

     

    :ReturnCode_0

    echo.

    Echo The PC %%a was reached

    Rem end

     

    The above is just a little piece of the batch file.

    There is a list of computers it needs to ping one and based on wither it is online it will do one set of things if it is offline it will do another thing.

    The issue is it is just pinging all the computers in the list of computers and then moving on to the next line in the BAT file.

    Is there a way to make it ping the first pc in the pclist.txt file if it is not online do what I need it to and then go back and ping the second in the list and so forth.

    Thanks in advance

    Monday, July 20, 2009 8:41 PM

Answers

  • Hello,

    i suggest you post this into a scripting newsgroup/forum. This one is related to IT-management.
    Best regards Meinolf Weber Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by tnetplus Tuesday, July 21, 2009 11:53 PM
    Tuesday, July 21, 2009 12:22 AM

All replies

  • Hello,

    i suggest you post this into a scripting newsgroup/forum. This one is related to IT-management.
    Best regards Meinolf Weber Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by tnetplus Tuesday, July 21, 2009 11:53 PM
    Tuesday, July 21, 2009 12:22 AM
  • Thanks

    Tuesday, July 21, 2009 4:12 PM