Hello I'd like to block some websites directly from the command prompt.
echo like this:
0.0.0.0 websitename.com
How can I do this? (OS: Windows 7)
Locate hosts file, right-click it and choose Properties. Navigate to the Security tab and click the Edit button. You should see the list of users and groups on your PC that have access to the hosts file. If your user name or group is on the list, click it and make sure that it has Permissions set to Full control.
You don't need to reboot. Any changes you make to the hosts file are immediate. You used to need to reboot for changes to take effect in Windows 9x.
Click File in the menu bar at the top of Notepad and select Open. Browse the Windows Hosts File location: C:\Windows\System32\Drivers\etc and open the hosts file.
echo 0.0.0.0 websitename.com >> %WINDIR%\System32\Drivers\Etc\Hosts
the >>
appends the output of echo
to the file.
Note that there are two reasons this might not work like you want it to. You may be aware of these, but I mention them just in case.
First, it won't affect a web browser, for example, that already has the current, "real" IP address resolved. So, it won't always take effect right away.
Second, it requires you to add an entry for every host name on a domain; just adding websitename.com
will not block www.websitename.com
, for example.
Use Hosts Commander. It's simple and powerful. You can download it 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
...and many others...
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With