Solved

cant write to Windows hosts file

Posted on 2013-11-27
7
690 Views
Last Modified: 2013-11-29
Hello EE,

I am signed in as a local admin on a windows 7 computer.  I am not signed as THE local admin though.  I am trying to update the hosts file for accessing other websites from another domain.  This is working on other computers currently that I have adjusted for these websites.  if I log on as THE local admin I can make the change.  If I logon as one of the other local admin accounts that are part of the local administrators group it doesnt work.  I have even gone as far as putting one of the local admin accounts as owner of the hosts file and yet when logged on as that account still can not make change to hosts file.  what can i do to correct this problem?  Thanks for your help!
0
Comment
Question by:12string
7 Comments
 
LVL 35

Accepted Solution

by:
Mahesh earned 500 total points
Comment Utility
Try below

open cmd with run as administrator

then change directory to C:\windows\system32\drivers\etc

then type "notepad hosts" and enter

Now make your modifications and save and close

Mahesh
0
 
LVL 44

Expert Comment

by:Darr247
Comment Utility
By default, everything in %windir% and deeper is owned by "TrustedInstaller"

Take Ownership of the %windir%\System32\etc\drivers\etc folder, then give the new owner (I suggest giving ownership to the Administrators group) Full Control on the Permissions tab.Permissions - Administrators - Full Control (click for larger)
THEN running notepad as administrator will be able to save changes there.
0
 

Author Comment

by:12string
Comment Utility
Thank you MaheshPM that is another option but how do I change that back so that one doesnt have to do that step?  if the account is in local administrators and local admins have that ability then why does this happen?
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 35

Assisted Solution

by:Mahesh
Mahesh earned 500 total points
Comment Utility
The User Access Control are still enabled on Windows 7 machine by default....which forces you to open cmd \ applications with run as administrator

You can disable these controls through Control Panel \ user accounts \ change user account settings  and just pull the slider to complete bottom (Never Notify)

OR you can disable all UAC through gpedit.msc under computer configuration\windows settings\security settings\local polices\security options, you need to disable those settings starting from user access control (specifically admin approval modes)

OR you can use domain level GPO to disable above these settings

OR you can just disable through registry also.

Its not recommended to modify NTFS security on System folders

Mahesh
0
 

Author Closing Comment

by:12string
Comment Utility
Thank you Mahesh I was wondering whether I would have to use gpedit but didnt want to waste the time looking the exact location.

Also Thanks Darr247 I did do that as well, before I came to EE, but still got same problem.  took ownership using a specific local acct and then logged on as that acct.
0
 
LVL 53

Expert Comment

by:McKnife
Comment Utility
Let me add something about the stuff behind this "effect".
First: UAC introduced these type of effects and UAC came with vista. How come that after 7 years, this problem is still not fully understood by anyone? :))

1. You are logged in as some admin, not as the account "administrator". With default settings, the UAC is off for the account "administrator" even when it's on for the rest. That's why it works with the admin called “administrator” and not with any others.

2. If, as in this case, the ACL of a file does hold the group "administrators" with at least change permissions and NOT everyone AND NOT authenticated users [and not your own account] - then you CANNOT modify the file EVEN when you are a member of the admins group. [By the way: the ownership does not matter]
Why is that so? Because of the UAC. The UAC introduced the concept of elevation [see 3.]. Without "elevating", members of the admin group are treated as weak, restricted users. From the perspective of the ACL, they don't even belong to the group administrators!

3.How to elevate? Now for the most important part...
The host file is usually opened with notepad. Microsoft, in their enormous generosity, has been providing this square and simple program for ages. Problem: it is NOT UAC-aware! It won't TRIGGER elevation. The process of elevating (after "dimming the screen") would need you to click ok on a dialogue that asks for consent, that's all. But notepad is too simple to provide that :) It has not been made compatible with MS’ own technology. Too bad. By the way: task manager is another program that misses to trigger elevation under some circumstances. Poor work.
What can we do? We can…
-modify the ACL of the file to simply hold hold our own account name! or…
-elevate the viewer (notepad) manually by right clicking notepad.exe and selecting “run as administrator”. Or…
-use runas on notepad providing the credentials of the “real” administrator. Or…
-save the file somewhere else and later, push it over to its final destination using explorer! Explorer is UAC aware and will trigger elevation while we move that file and overwrite the old one.
Turning off UAC is not the way to go, believe me.

4. There is even more to it: there is a little known security feature called “mandatory integrity controls/levels” (“MIC”/”MIL”) that can also cross your plans! Think of it as some kind of extra security layer next to the NTFS ACL. If some files/folders are set to have an MIL of “high”, then only elevated processes may write to it. Writing to the root of c:\ is such an example, too.
ILs can be read out and modified by tools like chml.exe

Spread the word
0
 

Author Comment

by:12string
Comment Utility
Thanks McKnife for the explanation.  To answer your question:

<How come that after 7 years, this problem is still not fully understood by anyone?>

My customers were more win xp than win vista, there was very little need to know or work with win vista ergo the need to ask why this problem exists.

Thanks for the insight and yes I will pass the info on, I know quite a few people will be interested in this answer
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now