![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-09-23 12:53 |
47,812 topics / 349,917 posts / today 0 new / 48,273 members |
| DOS批处理 & 脚本技术(批处理室) » Check if the specified character exists in the hosts file. If not, add it and give a prompt |
| Printable Version 7,186 / 1 |
| Floor1 chguishan | Posted 2020-12-19 11:31 |
| 新手上路 Posts 2 Credits 2 | |
|
```batch
@echo off rem 检查hosts中是否存在指定的记录 find /i "172.16.5.1 aa.aaaa.com" "%windir%\system32\drivers\etc\hosts" >nul 2>nul if %errorlevel% equ 0 ( start "" "http://aa.aaaa.com" ) else ( echo 172.16.5.1 aa.aaaa.com>>"%windir%\system32\drivers\etc\hosts" start "" "http://aa.aaaa.com" ) pause ``` |
|
| Floor2 chguishan | Posted 2020-12-20 21:08 |
| 新手上路 Posts 2 Credits 2 | |
|
@echo off
set ip=172.16.5.1 set domain=aa.aaa.com set hosts="%windir%\system32\drivers\etc\hosts" find /i "%ip% %domain%" %hosts% if errorlevel 1 >>%hosts% ( echo. echo %ip% %domain% ) start "" "http://%domain%" |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |