Call a subroutine called :Sub passing it the line that's just been read. terminate) :Label1 Now there is a subsection called Label echo PingTest executed on ?te% at %time% > d:\tools\z.txt Type the words " PingTest executed on " along with the current date and time " but instead of typing them to the screen, pass them (using the > symbol) to a file called d:\tools\z.txt for /f %%i in (d:\tools\computers.txt do call :Sub %%i There's actually a bracket missing from this, so the correct line should read: for /f %%i in (d:\tools\computers.txt) do call :Sub %%i Loop through each line of the file d:\tools\computers.txt which presumably contains a list of machine names or IP addresses. goto :eof Go to the end of the batch file (i.e. Pause Put a prompt on the screen which says "Press any key to continue." and then wait until a key is pressed. It presumably contains a list of machine names or IP addresses one per line. This file must exist in the location specified. echo Cannot find d:\tools\computers.txt As the file called d:\tools\computers.txtwas not found then type " Cannot find Etc." to the screen. if exist d:\tools\computers.txt goto Label1 If there is a file called d:\tools\computers.txtthen jump to the section of the batch file called :Label1 echo. Using the sign means including the current line. Off Don't echo these batch file commands to the screen.
0 Comments
Leave a Reply. |