How to edit Windows 7 lmhosts file
"I'm trying to create a lmhosts file on my Windows 7 computer but I keep getting an error message that says Access to C:\Windows\System32\ drivers\etc\lmhosts.sam was denied. How can I edit lmhosts.sam so that I can create an lmhosts file on my Windows 7 computer?"
One of the security measures Microsoft took to protect Windows Vista and Windows 7 from malware was to make it harder to edit the lmhosts and hosts file.In older versions of Windows, malicious code would modify these files, which caused you to end up on Websites you didn't intend to see or potentially used your computer for other purposes you didn't intend. With the improved security, you need administrator privileges to edit the files, which takes an extra step than being an administrator account.
Assuming you are an administrator account when you are logged in, these steps should work to edit your lmhosts.sam file. First, open Notepad by right clicking on the application icon and choosing run as administrator. If you don't run Notepad as administrator, you won't be able to edit lmhosts.sam.
Next open the lmhosts.sam file in Notepad. The lmhosts.sam file is located in:
C:\Windows\System32\drivers\etc or if your system hard drive isn't C: the path is whatever your system path would be: %systemroot%\Windows\System32\drivers\etc
Once you open the file, simply modify the lines you need for the IP addresses you want to map to network names in the pattern IP address first network name second. So if you wanted to hardcode a resource named Jake in your lmhosts file, you would add the line:
Save the file as lmhosts (without the .sam) and your change will instantly be active.