|
Answer» :START set PRDDIR=c:\windows\system32\dns set BCKDIR=%PRDDIR%\backup set SCSFULDIR=%PRDDIR%\successful.log set UPDDIR=%PRDDIR%\update set LOGDIR=%PRDDIR%\log set DNSLOG=%LOGDIR%\update_dns.log set BOOT=%PRDDIR%\Boot-Files
REM CHECK for new zone files in update directory If not exist %UPDDIR%\db.* goto END_UPDATE del %SCSFULDIR%\* /Q >nul REM Time stamp DNS log file date/T >> %DNSLOG% time/T >> %DNSLOG%
REM Stop DNS process net stop dns if ERRORLEVEL 1 goto STOP_ERROR ----- REM NEED ALERT
REM Backup existing zone files copy %PRDDIR%\*.* %BCKDIR% >nul REM Copy in new zone files copy %UPDDIR%\*.* %PRDDIR% >nul copy %BOOT%\*.* %PRDDIR% >nul set TRY=1
:RESTART_DNS
REM Restart DNS process net start dns if not errorlevel 1 goto RESTART_OK
If %TRY%==2 goto RESTART_ERRORNEED alert has to be triggered-----☻
REM Recover backed up zone files copy %BCKDIR%\*.* %PRDDIR% >nul copy %BOOT%\*.* %PRDDIR% >nul set TRY=2 goto RESTART_DNS pause
:STOP_ERROR
echo DNS stop FAILED >> %DNSLOG% goto END_UPDATE
:RESTART_ERROR
echo DNS restart FAILED >> %DNSLOG% goto END_UPDATE
:RESTART_OK
REM Remove new zone files from update directory If %TRY%==1 del %UPDDIR%\* /Q >nul rem Update successful ☺
If %TRY%==1 echo DNS restart SUCCESSFUL >> %DNSLOG%
If %TRY%==1 echo DNS restart SUCCESSFUL > % SCSFULDIR % If %TRY%==2 echo DNS restart RECOVERED >> %DNSLOG%
:END_UPDATE
The idea to add the successful. log is to create another batch file to run in unification and check for a file in the path. If the file is missing then we need to trigger an alert so total there are 3 instances of alert.
I need the syntax to create the batch file which will look for the file successful.log and if not exist send the net send command to the list of ppl identified by their login accounts Code: [Select]if not exist %SCSFULDIR% net send user "message text"
Replace user and "message text" as appropriate. You can also use the msg command if you prefer.
Not sure why you need the exist test. Does not ENTERING STOP_ERROR or RESTART_ERROR indicate an error?
Good luck. I tried using netsend but it checks for name resolution and is not able to resolve the user. It only recognizes user LOGGED on to the machine. Though net send with machine name is possible. the exist command is an error indication but it doenst send any alert. this file is being run on a remote server so i dont monitor the machine.
Just want to verify if error level 1 is correct command? and what does the "copy %BOOT%\*.* %PRDDIR% >nul" do?
|