Compartilhar via


Modifying HOSTS file in Vista...

When you trying to modify the "Windows\system32\drivers\etc\hosts" file to add some local dns mappings in Vista, the system will not allow you to save the file. It's because of the tighten security in Vista.

to solve this, refering to this KB, run your editor by right-clicking it and "run as Administrator", then will be able to save the file.

or by referring to Matthew's post, just grab the ownership of the HOSTS file so that one will be able to edit it without having administrator priviledges.

(by running cmd.exe as administrator...)

takeown /f c:\windows\system32\drivers\etc\hosts
icacls c:\windows\system32\drivers\etc\hosts /grant yourusername:f

FYI.

Technorati tags: microsoft, windows, vista, security, hosts, dns

Comments

  • Anonymous
    July 16, 2007
    I might be being stupid here, but is it not the whole point of the host file not being owned by you the point of the security measure. I.e You run a trojon on your machine under you priviledges then it has no access to the host file. Surely you should just put up with the minor inconvience of having to start you editor as admin then take ownership of the file?

  • Anonymous
    July 16, 2007
    Hi James: Of course it's just like what you said the whole security meanings of that the file's ownership is not the current user. this is just one of the option of grabbing the ownership to minimize the steps of modifying the hosts file especially if you are a web developer and often need to do lots of local tests. one should consider the risks v.s. the conveniency of doing one of the above actions. the main point of this post is just to notice people how to modify HOSTS file in a Vista environment if one needs to... :) Rex

  • Anonymous
    July 16, 2007
    The comment has been removed

  • Anonymous
    July 16, 2007
    The comment has been removed