Sometimes, I must edit hosts file that necessary to access website.
But I use different computer and I don't want to edit each computer.
I install Chrome portableApp in my USB flash drive, Is there any way to not edit computer local hosts file and access website?
How do you configuration portableApps to use hosts file in USB flash drive? Chrome or Firefox.
You are here
How do you take hosts file and work by USB flash drive
May 4, 2011 - 10:38pm
#1
How do you take hosts file and work by USB flash drive
If the reason you don't want to be editing the host PC's HOSTS file each time is that it's too involved, you can automate the provess with a very simple batch file. Here is how (naturally, your user must have sufficient privilege to edit the host PC's HOSTS file or this will not work).
Place a copy of your HOSTS file on your USB flash drive. Edit this copy so the first line is blank.
In the same directory on your USB flash drive, create a text file named EditHosts.cmd. Edit this file with Notepad and add the following two lines:
copy /Y c:\windows\system32\drivers\etc\hosts c:\windows\system32\drivers\etc\hosts.org
type hosts >> c:\windows\system32\drivers\etc\hosts
Save the file and make sure Notepad does not add its usual '.txt' extension to it. When you double-click on your new batch file 'EditHosts.cmd', it will append all the entries from your HOSTS file to the host PC's HOSTS file. Using the double right arrows ( >> ) will cause it to append to the existing file. Using a single right arrow ( > ) will cause it to overwrite the existing file.
If you don't want to leave information from your HOSTS file entries on the host PC, you can easily remove them with another batch file. Name it 'UnEditHosts.cmd'. Edit the file and add the following two lines:
del /f /q c:\windows\system32\drivers\etc\hosts
ren c:\windows\system32\drivers\etc\hosts.org hosts
Save the file, again remembering not to let Notepad add the .txt extension. When you double-click this file, it will delete your modified HOSTS file and resore the original one.
If there's some other reason you don't want to edit the host PC's HOSTS file, look into the Windows 'fsutil' utility. 'fsutil' can create a "hard link" from the host PC's HOSTS file to your HOSTS file on your USB flash drive. When the OS tries to access the PC's HOSTS file, the hard link will redirect the inquiry to the copy on your USB flash drive. A batch file to issue the correct 'fsutil' command should be in the same directory on your USB flash drive as your personal HOSTS file and its contents would look something like this:
FOR /F "Tokens=*" %%D In ('CD') Do Set CD=%%D
fsutil hardlink create %CD%hosts c:\windows\system32\drivers\etc\hosts
Microsoft's information on the 'fsutil' utility is here:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs...
A third option is to use the IP addresses from your HOSTS file instead of the URL. In other words, if you have a line in your HOSTS file for Google.com ( 74.125.115.104 google.com ), when you want to go to Google, put the IP address ( 74.125.115.104 ) in your browser's address window rather than the URL ( google.com ).
Hope this helps!
Modifying the HOSTS files is really messy because you can really screw up connectivity if something goes wrong, especially if the host machine has a heavily modified HOSTS file. I'm sure there are ways to do DNS poisoning that are limited to the browser and don't require admin rights.
Vintage!
Thanks for your help, this is very detailed and useful.