PrimitiveType

Problem editing the hosts file in Windows Vista

When developing websites I often use the hosts file in Windows (C:\Windows\System32\drivers\etc\hosts) to map host names to IP addresses. I recently bought a new laptop with Windows Vista Business installed and found that I couldn't update the file.

The hosts file is not read-only, and as the system administrator I'd expect to be able to write to the file. However, I was getting the following error message when attempting to save the file in Notepad:

Cannot create the C:\Windows\System32\drivers\etc\hosts file.

The solution (or workaround) is to open Notepad by right-clicking on the program (in the All Programs menu, for example) and select "Run as administrator", then open the hosts file from within Notepad. You should now be able to edit and save the file as expected.

I guess this is a bug in Windows Vista as I already am logged in as administrator. Hopefully a fix will be available soon.