Reputation: 191
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.
Upvotes: 1
Views: 1257
Reputation: 41224
This will add a couple of entries to the HOSTS file, when run as administrator:
@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
Upvotes: 1