Can't edit hosts file in Windows Server 2012

When trying to edit the hosts file, I get a "The process cannot access the file because it is being used by another process."

I know the file is controlled by the SYSTEM.  I tried opening NotePad with administrator rights but that did not help. I am not logged in as the system, but as an administrator and have full control on the  C:\Windows\System32\drivers\etc folder.

How can I edit the hosts file?
PBITAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Cliff GaliherCommented:
Some other process (non-standard) has that file then. Could be antivirus. Could be something more nefarious. Grab a tool like procmon and find what's holding the file handle.
1
Mohammed KhawajaManager - Infrastructure:  Information TechnologyCommented:
You need administrator privileges. Vat art command prompt as administrator and then run the following:

Notepad c:\windows\system32\drivers\etc\hosts
0
PBITAuthor Commented:
Already running notepad in admin mode.  That does not solve the problem.
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Luis MouraCommented:
Try in safe mode, and check if you can.
0
Cliff GaliherCommented:
Safe mode will likely (temporarily) solve the problem. But I'd still be concerned about why you can't edit in the first place. Again, that *isn't* normal. You'd be attacking the symptom and not the cause. If A/V is grabbing files that long for a simple scan, it'll interfere with other important processes. And if it isn't A/V..well...you probably want to know that too.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lee W, MVPTechnology and Business Process AdvisorCommented:
I agree with Cliff - this is not normal behavior and could be a virus.  

Step back.  WHY do you need to adjust the hosts file?

What does the host file look like now?

Could your Antivirus be "locking" it to prevent malware from doing something it shouldn't be?
0
Rakesh KapoorCommented:
Open Notepad by selection the option run as an administrator > click on File > select Open and then browse the path of host file i.e. c:\windows\system32\drivers\etc\hosts.

Make the changes and then save it. Hope it would fix the issue.
0
PBITAuthor Commented:
Thanks, I will look into the virus scanner potential.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2012

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.