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 "" "%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 -n 1 -w 3000 >NUL
) 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 -n 1 -w 5000 >NUL
echo File is not found on your machine.Please contact the admin or check in your windows directory.
ping -n 1 -w 3000 >NUL

Here we are editing the file and updating it accordingly.

Leave a Reply

Your email address will not be published. Required fields are marked *