|
- @echo off
- setlocal enabledelayedexpansion
- set ph=%windir%\system32\drivers\etc&set phn=!ph!\hosts
- type !phn! |findstr "\<130.1.1.121\>">nul
- if %errorlevel%==0 set "addr1=130.1.1.121"&set "addr2=130.1.1.122"
- type !phn! |findstr "\<130.1.1.122\>">nul
- if %errorlevel%==0 set "addr1=130.1.1.122"&set "addr2=130.1.1.121"
- if not defined addr1 (echo IP不对&pause&goto :eof) else echo 现IP地址为!addr1! 按任意键改为!addr2!&pause>nul
- (for /f "delims=" %%a in ('type !phn!') do (
- set aa=%%a & set aa=!aa:%addr1%=%addr2%!
- echo !aa!
- ))>!ph!\hosts.tmp
- del !phn!>nul&ren !ph!\hosts.tmp hosts>nul&pause
复制代码
%ph%改成你自定义的实际路径,试试 |
|