I have already published Edit Hosts File Remotely Part 1 but here is another trick so i have published here as a part2
Just by following below simple steps you can edit hosts file without opening it.
1. Create new notepad file and rename it as modifyhosts.bat
2. Now Open Modifyhosts.bat and type same as below
echo 127.0.0.1 google.com >> c:\Windows\System32\drivers\etc\hosts