[英]How to set texts in a hosts file (found in C:/windows/system32/drivers/etc folder) using command prompt or a batch file?
I want my system to automatically type certain statements in the host file in a sheduled time. 我希望我的系统在计划的时间内自动在主机文件中键入某些语句。 To do that I need to execute a batch file which contains the required commands for setting the statements in host file.
为此,我需要执行一个批处理文件,其中包含在主机文件中设置语句所需的命令。 What are the syntax required to set statements in a file, specifically a hosts file or a text file.
在文件(尤其是主机文件或文本文件)中设置语句所需的语法是什么?
This will add a couple of entries to the HOSTS file, when run as administrator: 当以管理员身份运行时,这将在HOSTS文件中添加几个条目:
@echo off
attrib -r -a -s -h C:\WINDOWS\System32\Drivers\etc\hosts 1>nul
C:\WINDOWS\System32\Drivers\etc\hosts >> echo 200.100.10.20 www.bogus.com
C:\WINDOWS\System32\Drivers\etc\hosts >> echo 200.100.10.22 www.fake.com
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.