BAT string Substitution

Source: Internet
Author: User
Tags goto
@echo off
Color 0F
SET path=%systemroot%\system32\drivers\etc\hosts


SET mirror_server_ip_domain=10.146.217.77 FJS-CTI-DP1
SET mirror_server_domain= "FJS-CTI-DP1"


SET main_server_ip_domain=10.123.154.251 KNR-CTI-DP2
SET main_server_domain= "KNR-CTI-DP2"






The @echo initializes the しました.
Copy "\appupdate.exe" "C:\Program files\mit\appupdatev2\"
CD \
C:
CD%systemroot%\system32
findstr%mirror_server_domain%%PATH% && Goto Addmainserveripdomain
Goto Addmirrorserveripdomain


: Addmirrorserveripdomain
@attrib-R%PATH%
@echo. >>%PATH% & @echo%mirror_server_ip_domain% >>%path%
@attrib +r%PATH%
@echo ミラーサーバーの setting するのが append しました.
Goto Addmainserveripdomain


: Addmainserveripdomain
findstr%main_server_domain%%PATH% && Goto Exitblock
@attrib-R%PATH%
@echo. >>%PATH% & @echo%main_server_ip_domain% >>%path%
@attrib +r%PATH%
@echo.
@echo プライマリサーバーの setting するのが append しました.
Goto Exitblock


: Exitblock
Pause>nul

Exit


String substitution

@echo off&setlocal
Set f= "C:\MIT\QuickCRM\login\CTIConfig.cfg"
Set src=192.168.1.82
Set dst=192.168.0.254


for/f "Usebackq delims="%%a in (%f%) do (
If not defined flag Cd.>%f%&set flag=1
Set V=%%a
Setlocal enabledelayedexpansion
Set v=!v:%src%=%dst%!
echo.! v!>>%f%
Endlocal
)


Goto:eof

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.