Windows – How to refresh hosts file without rebooting
windows
On Windows, how do you refresh the hosts file without rebooting?
Best Answer
You don't need to reboot. Any changes you make to the hosts file are immediate. You used to need to reboot for changes to take effect in Windows 9x. That is no longer the case.
However, you may need to restart any applications that do internal hostname or DNS caching, such as web browsers.
I've had success with SysinternalsProcess Explorer. With this, you can search to find what process(es) have a file open, and you can use it to close the handle(s) if you want. Of course, it is safer to close the whole process. Exercise caution and judgement.
To find a specific file, use the menu option Find->Find Handle or DLL... Type in part of the path to the file. The list of processes will appear below.
If you prefer command line, Sysinternals suite includes command line tool Handle, that lists open handles.
Examples
c:\Program Files\SysinternalsSuite>handle.exe |findstr /i "e:\" (finds all files opened from drive e:\"
Changes to environment variables should take effect immediately, if you make the change via the main Properties dialog for the computer in question (go to My Computer | Properties | Advanced | Environment Variables). After the changes are saved, Explorer broadcasts a WM_SETTINGCHANGE message to all windows to inform them of the change. Any programs spawned via Explorer after this should get the updated environment, although already-running programs will not, unless they handle the setting change message.
I'm not able to tell from your problem description what specific problem you're having with this. Can you tell us more about the specific scenario that isn't working?
Best Answer
You don't need to reboot. Any changes you make to the hosts file are immediate. You used to need to reboot for changes to take effect in Windows 9x. That is no longer the case.
However, you may need to restart any applications that do internal hostname or DNS caching, such as web browsers.