Online Help > Support/Resources > Tips And Tricks

Edit Hosts File

Description

 

IT technicians, as well as web developers, often need to edit the Windows hosts file. This requires starting your favorite editor using elevated privileges (obviously only if UAC is active), browsing for the hosts file which is deep in the windows folder and enclosed in a hidden folder on top of that.

 

For your own machine you can create a shortcut to achieve you goal, but our experience tells us that most people don't bother with it, ending up losing precious seconds every time they must modify the hosts file.

 

What better tool then one that you use every day, which is already running in the notification area, to implement a solution with. If the machines you work on have the same setup, this will work on all of them.

 

Simply create a session with the proper settings.

 

Steps

 

1. Create a new Command Line session and enter a session name.

 

Command Line session

Command Line session

 

 

2. In the Execution Mode tab, check the Run as Administrator option.

 

 

3. In the General tab,click on the ellipsis button and select your editor of choice in the Run text box. Then, paste the following after the name of the program: "c:\Windows\System32\drivers\etc\hosts". Ensure a blank space separates the two and include the double quotes.

 

Command Line Session - Run

Command Line Session - Run

 

Close your editor before proceeding with those steps. If your editor is already running, it will not elevate the privileges.  We have implemented an AutoHotKey script that closes the editor of choice, but being that it shuts off without saving pending changes, it is not a risk-free solution. It will all depend on your chosen editor's reaction to the WM_QUIT message.

 

It is a simple and efficient solution. You can use this for any tool you use regularly. Paired with shared data source it makes for a powerful library of tools for your team.

 

Alternative if you want to use the Parameters tab

 

Some people wish to use the parameters tab because, upon launching, it will display a dialog where you can confirm the value of the parameters and even allows you to change them for whole new values.

 

1. Create a new Command Line session and in the Execution Mode tab, check the Run as Administrator and disable the Use Shell Execute option.

 

 

2. In the General tab,click on the ellipsis button and select your editor of choice in the Run text box. Then enter "{1}" after the name of the executable, keeping a space between the two values and including the quotes.

 

Command Line - General tab

Command Line - General tab

 

3. In the Parameters tab, set Parameter # 1 type to Text and then enter the following in the Default Value: c:\Windows\System32\drivers\etc\hosts

 

Command Line session - Parameters tab

Command Line session - Parameters tab

 

This is helpful when mostly using the tool with a certain file, but occasionally need to edit another file. You could have separate entry for each file you commonly edit, but this shows how flexible Remote Desktop Manager can be.