Edit hosts file in Windows 7

By default you cannot browse to C:\Windows\System32\drivers\etc and edit the hosts file directly in Windows 7. The edit the hosts file do the following:

1. From the start bar search for notepad and right-click on it and select Run as administrator per the below:

20130609003122

2. Browse to C:\Windows\System32\drivers\etc, select the hosts file and click Open:

20130608192422

3. Once open edit the hosts file per your requirements:

20130609000237

4. To save time and superfluous clicks, you can accomplish Steps 1-3 above by running a single command, see below:

runas /user:MYPC\administrator "notepad C:\Windows\System32\drivers\etc\hosts"

Replace MYPC\administrator with your PC name and admin account. Once you hit enter you will then be prompted for the password of the specified account, enter it and the hosts file will load up.

If you envisage running this command regularly and want to avoid entering the password in every time use the /savecred parameter, per the below:

runas /user:MYPC\administrator /savecred "notepad C:\Windows\System32\drivers\etc\hosts"

You will no longer be prompted for the password whenever running the command above thereafter. The syntax for the runas command can be found here. You can also dump the command in a batch file and run it when needed.

5. Save the changes and then open the command prompt and then run the following command:

c:\>ipconfig /flushdns

This will purge the DNS cache and the settings in your host will take effect from this point onwards:

20130609005037

Note: This is only required if the domain added to the hosts file (www.yourdomain.com) was visited prior to editing the hosts file. It is good practice to purge the dns cache in case any stale DNS information resides there.

6. Load www.yourdomain.com in your browser and the connection will direct to the IP address stated in the hosts file.

Install Telnet client on Server 2008 & Server 2008 R2

On a fresh build of Server 2008, Server 2008 R2 and Windows 7, the telnet client is not installed so running a normal telnet command will yield the following response:

'telnet' is not recognized as an internal or external command, operable program or batch file

The quickest and easiest way to install the telnet client is to run the following command :

pkgmgr /iu:"TelnetClient"

It installs the client silently in the background and only takes a few seconds after which you can telnet to your heart’s content:

The install can be done via the GUI also by performing the steps listed here.