Novell Home

Adding a Hosts Entry Remotely

Novell Cool Solutions: Trench
By Andreas Bach

Digg This - Slashdot This

Posted: 13 Feb 2001
 

Works for: GroupWise, ZENworks for Desktops, Novell Small Business Suite, NetWare

Introduction

These instructions are for adding an entry, NGWNAMESERVER, to the bottom of a Windows Hosts file. This is one way used by GroupWise to find the PostOffice.

With very little modification, ANY other lines could be added to the Hosts file. Several Novell products use entries in the Hosts file. For example, NetWare could benefit from an entry pointing to the NDS Tree, or preferred Server. ZENworks for Desktops v3 uses ZENWSIMPORT to know where to send workstation registration information.

I needed this at a customer site where the DNS was hosted at the ISP, but they wanted the newly installed GroupWise client to automatically find its PostOffice without bugging the user. I figured I'd write up the procedure to do so, and share it with Cool Solutions. The Users weren't all authenticating to NDS so I couldn't depend upon the usual method of assigning NDS rights for the User object to browse the POA object's properties.

Remember, this process is generally only required if you can't put the information into a local DNS server, where it belongs!

Overview

This procedure describes how to add an entry to a Windows 95/98/NT/W2K workstation's "hosts" file. This file is to help locate servers in a TCP/IP environment. The specific entry we want to add is NGWNAMESERVER. This is a reserved name that tells the GroupWise 5.x client software where to find a PostOffice on the network.

These instructions could also be used to add ANY desired entry to a windows Hosts file.

Normally Host lookup information is managed centrally by adding the entry to the DNS server. This procedure applies if you can't do that easily, and must rely on updating a Hosts file on everyone's workstation with the info.

Instructions

NOTE: In this procedure, I activated the change using group membership, simply for my own convenience. I could have used the "if OS_Version" login script syntax also, but didn't look into it. Also, I used an Include file in my login script, but could have just as simply called @f:\public\fix9x.pif directly.

  1. Start by creating a group called "Win9x", and add your target users.
  2. In your login script (container, profile, or user as appropriate) add the following 4 lines:

    If member of "Win9x" then
    Write "Adding GroupWise Setting."
    INCLUDE f:\public\include.txt
    End

  3. Then create a file "include.txt" that contains only one line:
    @f:\public\fix9x.pif
  4. If you don't have a "fix9x.pif" file, simply run "fix9x.bat" (see below), and Windows will make you one and put it into the same directory as fix9x.bat. I recommend using a Win95/98 workstation to make this PIF file for full compatability.
  5. Next Right-click on fix9x.pif and select Properties, and click on Program and then make sure the following are set:

    Cmd line: fix9x.bat (remove any path references!)
    Working Directory: (make this blank!)
    Run: "Minimized" and
    "Close on Exit" is CHECKED.

  6. Say OK to save and exit. As long as the PIF and BAT go together into the same directory they will work together!

Fix9x.BAT

"Fix9x.BAT" is the following text file and it does the real magic:

  • @echo off
  • Rem Fix9x.bat
  • Rem Add NGWNAMESERVER entry to Hosts file on Win95/98 machines
  • Rem Will only run once. Uses hosts.org as the flag file. Rename this if desired to have
  • Rem re-run occur eg. hosts.1, hosts.2 etc
  • Rem If you need to undo this whole process, copy hosts.org back onto hosts
  • Rem %windir% is the subdirectory directory Windows is running from
  • If exist %windir%\hosts.org goto done
  • copy %windir%\hosts %windir%\hosts.org
  • copy %windir%\hosts.org + f:\public\ngwset.txt %windir%\hosts
  • :done

We're almost done here, so please be patient!

Ngwset.TXT

Now create a file called "ngwset.txt" with the following 3-line syntax:

  • <blank line>
  • # Add line for GroupWise to find its PostOffice
  • 10.0.0.1    ngwnameserver <Enter>

Make sure you hit <Enter> at the end of the ngwnameserver line when you edit this file, or things won't work properly. The IP Address can be of ANY GroupWise 5.x Post Office on your LAN, but it should usually be one that is near the users to prevent any needless WAN traffic.

And that's all you have to do. Put all these files you've created into f:\public, and try it out!

If you manually run f:\public\fix9x.pif you should notice your Windows hosts file get updated. On most machines, %windir% points to C:\Windows (or C:\WinNT). Run it again, and nothing should change.

Delete hosts.org and remove the NGWNAMESERVER entry from your hosts file. Now login as a member of the Win9x group, and it should update your hosts file as above. Login a second time and nothing should change.

FixNT.BAT

NOTE: For Windows NT, and Win2K, create a different group: "FixNT", and call FixNT.bat (and PIF) that is as follows:

  • @echo off
  • Rem FixNT.bat
  • Rem Add NGWNAMESERVER entry to Hosts file on WinNT/Win2K machines
  • Rem Will only run once. Uses hosts.org as the flag file. Rename this if desired to have
  • Rem re-run occur eg. hosts.1, hosts.2 etc
  • Rem If you need to undo this whole process, copy hosts.org back onto hosts
  • Rem %windir% is the subdirectory directory Windows is running from
  • if exist %windir%\system32\drivers\etc\hosts.org goto done
  • copy %windir%\system32\drivers\etc\hosts %windir%\system32\drivers\etc\hosts.org
  • copy %windir%\system32\drivers\etc\hosts.org + f:\public\ngwset.txt %windir%\system32\drivers\etc\hosts
  • :done

Hopefully this will save you time and trouble and eliminate going around to everyone's workstation for such a simple change as needing to put an entry in a Windows Hosts file!

Reader Comments

Joel Lovelien

Is there a benefit to doing it as suggested in the tip? I've added host entries using the 'text files' options and just added the string to the end of the file. I'm curious to know the benefit of doing this?

and

Paul Langton

In regards to the article "Adding a Hosts Entry Remotely" recently published on your site, why would you not use the Text File settings of an application object to add an entry to the hosts file? I had a situation here where 1500 users needed an entry in there straight away, and with ZEN and the text file section, it was easily and quickly achieved. Seems like a more elegant solution to me.

Andreas: You're absolutely right, but my guys needed this done and deployed in about 5 minutes!

I told them that even the ZENworks Starter Pack would have been a better, more flexible, added-value, business benefit solution, but they said "Yea, whatever. Can you still do it right now?"

Maybe next time!

Glad you thought of the "Text File" solution from ZENworks. I try and educate folks that once they have ZENworks installed, there isn't much they can't do on a workstation, remotely and automatically, but in this case it was a quick one-off and they are definitely looking at it otherwise.


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell