【发布时间】:2015-06-12 08:11:51
【问题描述】:
我想使用这个批处理脚本通过 windows 批处理自动将新条目添加到我的主机文件中。
我只想在我在办公室时编辑主机文件。我想说这样的话: if(network name=='OfficeWifi') 做改变...
@echo off
set hostspath=%windir%\System32\drivers\etc\hosts
// if(network name=='OfficeWifi')
echo 81.155.145.48 ns1.intranet.de >> %hostspath%
exit
感谢您的帮助
【问题讨论】:
-
如果您多次运行,这将多次添加该条目。您还希望在不在该网络时删除该条目。您不想自己编写脚本。以superuser.com/questions/663183/… 为例。
标签: windows batch-file cmd network-programming