Quick access to your hosts file

15 December 2007

I access my hosts file every now and then. So after the third or fourth time of navigating down the "WINDOWS, system32, what was it next?" route, I created a batch file to make it a 3 second job.

If you use your hosts file for local development, or if a domain name hasn't propergated and you can't wait, this could be of interest to you.

  1. Create a new text file and save it as hosts.bat
  2. Find your host file, which for me on Windows XP Pro and Vista is in C:\WINDOWS\system32\drivers\etc\
  3. Add the following line to the batch file making sure it points to the where ever your hosts file is: notepad C:\WINDOWS\system32\drivers\etc\hosts
  4. Save the batch file and move it to C:\WINDOWS\system32\
  5. Now click Start > Run > then type hosts and press return

As you can imagine, you can use this technique for all sorts of other shortcuts, stopping and starting services, opening up files in the deepest of directory structure etc.