Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
564 views
in Technique[技术] by (71.8m points)

Batch script that will allow to search a particular IP and change it to a new IP address in a .ini file

I want to write a batch script, that will allow to search a particular ip and change it to a new ip address in a .ini file.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try below updated code, please let me know if you still face issues

 cls 
 @Echo Off 
 SetLocal EnableDelayedExpansion 
 if exist new.ini ( del /s /q new.ini ) 
 set "search=1.1.1.1"
 set "search2=2.2.2.2"
 set "replace=7.7.7.7"
 set "replace2=8.8.8.8"
 for /F "tokens=*" %%a in (Apservice.ini) Do ( 
 Set "filevalue=%%a" 
 Set filevalue=!filevalue:%search%=%replace%!
 Set filevalue=!filevalue:%search2%=%replace2%!
 Echo !filevalue!>>new.ini 
 ) 
 move /y new.ini Apservice.ini 
 ause

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...