Batch script to check whether a particular entry exist or not and update the file.We are taking backup of the original file and then editing it.
@echo off REM check for existence of the file if not exist %SystemRoot%\my_data (echo my_data FILE DOES NOT EXIST call :not_exist) REM check for existence of the entry find /c /i "188.8.131.52" "%SystemRoot%\my_data" > NUL if %ERRORLEVEL% equ 0 ( echo the entry [Mistonline] for data file already exists.Exiting from the process. echo Seems like you have already ran this script. ping 184.108.40.206 -n 1 -w 3000 >NUL exit ) else ( REM add the entry type %SystemRoot%\my_data >%SystemRoot%\my_data_bkp echo Username Mistonline. #My Local Site >>%SystemRoot%\my_data echo This window will close automatically. echo Updation Completed Succesfully. ping 220.127.116.11 -n 1 -w 5000 >NUL exit ) :not_exist echo File is not found on your machine.Please contact the admin or check in your windows directory. ping 18.104.22.168 -n 1 -w 3000 >NUL exit
Here we are editing the file and updating it accordingly.