您好我想直接从命令提示符阻止某些网站。
像这样回应:0.0.0.0 websitename.com
我该怎么做? (操作系统:Windows 7)
答案 0 :(得分:38)
echo 0.0.0.0 websitename.com >> %WINDIR%\System32\Drivers\Etc\Hosts
>>
将echo
的输出附加到文件。
请注意,有两个原因可能无法满足您的需要。您可能已经意识到这些,但我提到它们以防万一。
首先,它不会影响Web浏览器,例如,已经解析了当前的“真实”IP地址。因此,它不会立即生效。
其次,它要求您为域中的每个主机名添加一个条目;例如,只需添加websitename.com
不阻止www.websitename.com
。
答案 1 :(得分:21)
使用主持人指挥官。它简单而有力。翻译的描述(来自俄语)here。
hosts add another.dev 192.168.1.1 # Remote host
hosts add test.local # 127.0.0.1 used by default
hosts set myhost.dev # new comment
hosts rem *.local
hosts enable local*
hosts disable localhost
......和其他许多人......
Usage:
hosts - run hosts command interpreter
hosts <command> <params> - execute hosts command
Commands:
add <host> <aliases> <addr> # <comment> - add new host
set <host|mask> <addr> # <comment> - set ip and comment for host
rem <host|mask> - remove host
on <host|mask> - enable host
off <host|mask> - disable host
view [all] <mask> - display enabled and visible, or all hosts
hide <host|mask> - hide host from 'hosts view'
show <host|mask> - show host in 'hosts view'
print - display raw hosts file
format - format host rows
clean - format and remove all comments
rollback - rollback last operation
backup - backup hosts file
restore - restore hosts file from backup
recreate - empty hosts file
open - open hosts file in notepad