Page 1 of 1

Hosts file is locked

Posted: Wed Jul 26, 2006 7:06 pm
by hawleyjr
On my Winxp dev machine running xampp lately I have been unable to modify the hosts file

C:\WINDOWS\system32\drivers\etc\hosts

As you know this file contains the mappings of IP addresses to host names and is needed for virtual hosts.

The error I'm getting is the file is read only or is opened by another application.

Any ideas how to unlock this file? Or figure out what application is using it.

yes, I've right clicked and made sure it's not 'read only' :roll:

Posted: Wed Jul 26, 2006 8:34 pm
by neophyte
Hmm Sometimes I've had programs hang on to files even though I think the programs was closed. Lately I've had trouble with Programmers Notepad. Try looking at your applications manager or reboot.

Posted: Wed Jul 26, 2006 8:50 pm
by AKA Panama Jack
I can guarantee that XAMPP isn't the one doing that. It doesn't access that file at all.

It sounds like you have some network program that is locking the file. Have you added anything new from just before the problem happened to now, other than XAMPP?

As to finding out what application has hold of it I wish I knew. If someone knows how to track what programs have locks on what files I would love to know it as well. I have had windows screw things up like that as well.

When that has happened to me it has at least been on a file I wanted to delete. What I have had to do in the past is...

1. Reboot and tap F8 while rebooting until the boot screen appears.

2. Select boot with Safe Mode Command Prompt.

3. CD to the directory where the file is located.

4. Delete the file and reboot.

5. Then use a registry cleaner like Norton's WinDoctor to remove any registry entries that might have been associated with the deleted file.

A pain in the ass but about the only way I have found to fix the problem when it occurs. You can do basically the same thing but make a backup copy of the hosts file before you do this. Then copy it back when you are finished.

Posted: Wed Jul 26, 2006 9:25 pm
by neophyte
WOW, I shouldn't say it but I can't resist.

Windows sucks.

Posted: Wed Jul 26, 2006 10:15 pm
by Benjamin
I've encountered this problem before. I believe it's a bug in Windows. The only way I was able to to delete a file once was to..

1. Open the task manager
2. End Task on Explorer (not Internet Explorer)
3. Using the task manager, open a terminal
4. Delete the file
5. Using the task manager, restart Explorer

Spose that won't work for editing it though..