37

I have recently gotten a new computer and have upgraded to Windows 10 (though I suspect this is a problem in other versions as well.)

My user is an administrator. I have set UAC to the lowest level. I have changed owner to my user on the whole c:\ disk (including the hosts file.)

Still, when I run notepad c:\windows\system32\drivers\etc\hosts, edit the file, and try to save, it won't let me. If I run notepad as administrator first, then open the file, I can save without problems.

But, why, after the measurements I have taken, isn't my user regarded as an administrator user? What am I missing here, in order to make my user an actual administrator (and not just a regular user with some fancy label in user accounts)?

Updated question: When you have a user that is an Administrator, why is this user's permissions not affected by the security group Administrators, but rather the security group Users?

Tobb
  • 543

11 Answers11

31

The many people above me laid it out pretty clearly:

  • Copy to Desktop, Edit with Notepad and Save, Copy Back Which Would Overwrite the Previous Host File
  • Disable UAC
  • Launch cmd as an Administrator and than Type In "notepad..."
  • Use the Local Users and Group Manager (Ill Advised)

Option one on my list is how people have been doing it for years. There's only one UAC prompt for the return copy. It has been done like this since the Vista-era.

As what was explained to you earlier, you are an Administrator user. You can go through the effort to change this but it comes with a lot of risks. To make a comparison: you do not applications on Linux with "root" regularly but instead elevate with the "su" command or by logging in as "root."

Olivia
  • 411
12

The problem is actually very simple: in Windows 10 the hosts file is read-only by default. This means that even if you can access it with administrative privileges, you still cannot write to it. Furthermore (at least on my machine) this means that editing a copy as others suggested won't work, because it will be read-only too!

To be able to edit it you must first disable the read-only bit:

  1. Open the c:\windows\system32\drivers\etc\ folder in your file-manager;
  2. right-click the hosts file;
  3. select Properties;
  4. un-tick Read-Only;
  5. click Apply;
  6. click Continue (to perform the action with administrator privileges).

Then you can freely edit the hosts file with your favourite text editor (running it as an administrator). Remember to re-set the read-only bit after you're done to prevent other applications from modifying it without your knowledge.

A.P.
  • 471
9

Also if you have install tinyfirewall, there is a default option there that prevent the editing of the host file.

This applies to any firewall or antivirus you may have installed that has an option to lock editing of the hosts file

e.g. ZoneAlarm Free Firewall -> Settings -> Advanced Settings -> Lock hosts file

Aristos
  • 552
  • 8
  • 17
6

Open notepad.exe or any other text editor(sublime,notepad++) with administrator privilege (Right-click on the exe and select "Run as administrator"), edit the file and save.

Or,

Open Run prompt - Press Windows Key+R and type/paste folllowing command

powershell -c start -verb runas notepad.exe C:\Windows\System32\drivers\etc\hosts
1

Check your firewall settings. I just recently came across this issue. Only user of my PC and could not get that hosts file to cooperate. Tried to delete and antivirus pops up telling me it has protected me. I use Avira, so I into my real-time protection configuration, check the security tab and "Protect windows hosts file from changes." is on by default. I uncheck, apply, do my change, then check it back and apply. No issue at all once that option was unchecked.

1

Just because you are an Administrative user, does not mean that everything you do, you do as an administrator; it simply means that you have the ability to do so.

By default, your user runs just the same as any other user would, as themself.

When you try and preform administrative tasks - certain applications will be run with administrative privileges (such as when you click run as administrator).

Matt Clark
  • 2,104
1

I would not recommend doing this but if you give your user Full Control on that file it should work as you want it to. This is a security risk though, please think carefully if you really need this.

HoD
  • 3,522
0

I had this problem and eventually discovered that the hosts file was being locked by my firewall (Tinywall). Temporarily closing the firewall worked.

To find out what program is locking the file, I recommend a small utility called Unlocker by Cedrick Collomb. The download is no longer available on the author's website, but I was able to obtain it from Softpedia.

L J
  • 79
0

When you logon, you get handed a "Kerberos" token which defines your user as both administrator and user - regardless of what control panel tells you.

You can use local user manager (C:\windows\system32\lusrmgr.msc) to remove yourself from the users group and only be present in the administrators group - but this may cause more hassle than its worth.

Another hacky-style approach is to launch cmd as an admin and then "notepad C:......"

You could always take this one step further and launch cmd as an admin, from cmd - you can launch "taskmgr" and then kill and re-open "explorer.exe". Since taskmgr is running as an admin - processed launched under this context (explorer.exe - WINDOWS!) will also be in a pure administrator context - HOWEVER, this comes with a whole myriad of warnings:

  • Profile path will change to that of the administrator
  • everything you do will be as administrator (open door to virus, malware etc)
  • If you screw something up - you can cause a complete meltdown of your PC

UAC is meant to be there to allow you to stop and think berfore you do something which could have big ramifications.

Alternatively, disable UAC (Control Panel > User Account & Family Safety > User Accounts > Pick A User > Change User Account Control Settings) OR (Start > searc > UAC)

Fazer87
  • 12,965
0

Copy the hosts file to your desktop edit it, save it in the same place and then copy it back to system32\drivers\etc. the UAC popup answer with yes. that's it.

0

Changing the access rights for the User group to full control for the hosts file allowed me to save it without having to run stuff as administrator. The fact that my account is an administrator, and the administrators had full control of the file didn't allow me to edit it. Makes no sense. Go Windows!

Tobb
  • 543