国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > BAT > 正文

用批處理修改host文件的代碼

2020-07-26 20:21:38
字體:
來源:轉載
供稿:網友
@echo 127.0.0.1 baidu.com >>C:/Windows/System32/Drivers/etc/hosts
這樣就是換一行寫入。
如果還想換一行,就寫:
復制代碼 代碼如下:

@echo. >>C:/Windows/System32/Drivers/etc/hosts
@echo 127.0.0.1 baidu.com >>C:/Windows/System32/Drivers/etc/hosts
@echo 192.168.4.201 ibmrac1 >>C:/Windows/System32/Drivers/etc/hosts
@echo 192.168.4.202 ibmrac2 >>C:/Windows/System32/Drivers/etc/hosts
@echo 192.168.4.203 vip-ibmrac1 >>C:/Windows/System32/Drivers/etc/hosts
@echo 192.168.4.204 vip-ibmrac2>>C:/Windows/System32/Drivers/etc/hosts
@echo 172.16.1.53 ssosvr>>C:/Windows/System32/Drivers/etc/hosts


復制代碼 代碼如下:

@echo off
set stHosts=172.16.1.53 ssosvr
FOR /F "eol=# tokens=1 delims=" %%i in (%systemroot%/system32/drivers/etc/hosts) do if "%stHosts%"=="%%i" exit
echo %stHosts%>> %systemroot%/system32/drivers/etc/hosts



由于測試需要經常修改本機host,可以用腳本修改:
分別做兩個批處理,一個內網,一個外網,用的時候切換運行即可
如內網.bat
復制代碼 代碼如下:

cd /d %windir%/system32/drivers/etc
del hosts.bak //刪除原來備份文件
ren hosts hosts.bak //備份現在host
for /f "eol=# tokens=1,2" %%i in (hosts.bak) do call :checkvalue %%i %%j
goto end
:checkvalue
echo %2 | find /i "szshequ.com" //尋找制定記錄刪除
if %errorlevel%==1 (echo %1 %2 >>hosts)
:end

type C:/WINDOWS/system32/drivers/etc/hosts
type C:/WINDOWS/system32/drivers/etc/hosts | find "szshequ.com" && goto yes
::echo 192.168.2.188 szshequ.com >> ""
echo 192.168.2.188 szshequ.com >> C:/WINDOWS/system32/drivers/etc/hosts
echo 192.168.2.188 www.szshequ.com >> C:/WINDOWS/system32/drivers/etc/hosts
echo 192.168.2.188 bbs.szshequ.com >> C:/WINDOWS/system32/drivers/etc/hosts
echo 192.168.2.188 cost.szshequ.com >> C:/WINDOWS/system32/drivers/etc/hosts
echo 192.168.2.188 pp.szshequ.com >> C:/WINDOWS/system32/drivers/etc/hosts
echo 192.168.2.188 yh.szshequ.com >> C:/WINDOWS/system32/drivers/etc/hosts
echo 192.168.2.188 club.szshequ.com >> C:/WINDOWS/system32/drivers/etc/hosts
echo 192.168.2.188 shop.szshequ.com >> C:/WINDOWS/system32/drivers/etc/hosts
echo 192.168.2.188 images.szshequ.com >> C:/WINDOWS/system32/drivers/etc/hosts
echo 192.168.2.188 files.szshequ.com >> C:/WINDOWS/system32/drivers/etc/hosts
echo 192.168.2.188 ajax.szshequ.com >> C:/WINDOWS/system32/drivers/etc/hosts
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 华池县| 苏州市| 于都县| 垦利县| 金乡县| 汪清县| 金华市| 承德市| 河南省| 阿克苏市| 府谷县| 沂南县| 阿坝| 朝阳市| 淮滨县| 奉节县| 石嘴山市| 沙湾县| 攀枝花市| 秭归县| 高碑店市| 嘉义县| 新河县| 黄平县| 鄄城县| 嘉义市| 清新县| 宝山区| 诏安县| 浪卡子县| 荆州市| 隆化县| 屯留县| 湖口县| 广汉市| 长寿区| 安乡县| 育儿| 桃江县| 杂多县| 云霄县|