Many times there is a need to automate amendments to windows host files. Following is an example of adding a line to Windows Host file programmatically, using Windows command line.
Executing following command in Windows command line box:
echo 0.0.0.0 domain.com www.domain.com >> %WINDIR%\System32\Drivers\Etc\Hosts
, will append the following line to Windows host file and save it:
0.0.0.0 domain.com www.domain.com