Thursday, August 25, 2011

Script to clean the hosts file in windows

 Many of us are cleaning the hosts files in several occasion Eg: Virus cleaning. It's just a mater of cleaning the content of the file or deleting the existing hosts file and creating a new one, but in some cases it's hard to guide the users to do this. Most of the help desk people might experienced this :)



So i made a small script to do this work. This might save some time when supporting users remotely. Additionally i have added another line to flush the DNS entries...

 Type the following on a notepad and save it as a .bat file. Run the bat file with admin privilege.

@echo off
null > c:\Windows\System32\drivers\etc\hosts
ipconfig /flushdns

@echo off : suppress the output of the batch file
 null > [file name] : this will empty the file without deleting it
ipconfig /flushdns : Finally flush the cached DNS entries to clean up

Hope this will save someone's time one day...

No comments:

Post a Comment