n3tw0rkadm1n1strat0r
IS-IT--Management
Does anyone know how to make batch files wait after they have processes information...for example, it would wait to process all the information, write that info to a text file, and then send and email. The problem I am running into is that it only writes part of the data to a text file, not waiting till that part of the script is done and going straight to sending an email. Here's my script, thanks to anyone who can help.
I have tried the sleep and pause command and those both do not work...
Code:
@ECHO OFF
TITLE Website Check
REM -----------------------------------
REM
SET MachineList=MachineList.txt
SET ResultsFile=Results.txt
REM
REM -----------------------------------
CLS
ECHO.
IF NOT EXIST "%MachineList%" (
ECHO Cannot locate Machine List: %MachineList%
PAUSE>NUL
GOTO :EOF
)
ECHO Processing all machine names in %MachineList% . . .
ECHO.
FOR /f "tokens=*" %%M in (%MachineList%) do CALL :CHECK "%%M"
GOTO :EOF
:CHECK
SET Machine=%~1
SET Machine=%Machine: =%
PING -n 1 -w 1000 %Machine%>NUL
IF %ERRORLEVEL% NEQ 0 ECHO %Machine% did not respond at %Time%>>%ResultsFile%
CSCRIPT.EXE SENDMAIL.VBS -?
EXIT /B
:EOF
I have tried the sleep and pause command and those both do not work...