【发布时间】:2011-04-09 15:59:42
【问题描述】:
我想使用此批处理脚本通过 windows 批处理自动将新条目添加到我的主机文件中。
不幸的是,脚本只是在hosts文件中添加了一行,当我以管理员身份运行脚本时也是如此,所以出了什么问题?
@echo off
set hostspath=%windir%\System32\drivers\etc\hosts
echo 62.116.159.4 ns1.intranet.de >> %hostspath%
echo 217.160.113.37 ns2.intranet.de >> %hostpath%
echo 89.146.248.4 ns3.intranet.de >> %hostpath%
echo 74.208.254.4 ns4.intranet.de >> %hostpath%
exit
【问题讨论】:
-
将哪个添加到文件中。第一个还是最后一个?
-
真棒问题,很高兴找到准备好的信息并等待。
标签: windows windows-7 batch-file hosts