Batch script to check an entry exist or not and update the file

This Tutorial Has Been Viewed 335 Times.

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 "121.0.0.1" "%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 1.0.0.0 -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 1.0.0.0 -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 1.0.0.0 -n 1 -w 3000 >NUL
exit

Here we are editing the file and updating it accordingly.

VN:F [1.9.14_1148]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.14_1148]
Rating: 0 (from 0 votes)

Incoming search terms:





You will also be interested in ,

Leave a Reply

Proudly designed by Mistonline.in.
Affordable Seo PackagesSeo BlogEdu Backlinks