Novell Home

Naming a Computer after the Login Name

Novell Cool Solutions: Tip
By Dean Jorges

Digg This - Slashdot This

Posted: 10 May 2000
 

Version: ZENworks 2

To name the computer's name equal to the user's login name.

  1. Create a simple app. No exe needed here...
  2. In the registry tab, add this simple entry: [HKEY_LOCAL_MACHINE\System\ CurrentControlSet\control\ ComputerName\ComputerName]
    "ComputerName"="%login_name%"

Dean sent along his AOT in case it would help anyone implement this tip. Thanks, Dean!

Comments About this Tip

Rob Wheeler

When using ZEN to name a computer after a users login name, you can add the registryentry

[HKEY_LOCAL_MACHINE\system\ CurrentControlSet\Services\ VXD\MSTCP]"HostName"="%login_name%"

The user's Login Name will be entered as the DNS Host name and recognized by NetWare's DNS/DHCP Management console as the host name associated to the assigned IP Address.

Keith Larson

The tip of the week titled "Naming a Computer after Login Name" works well as long as nobody has more than a single concurrent login available. If a user tries to login to multiple workstations, Windows will detect that a computer with the same name already exists and won't allow the second one. One possible solution would be to include another unique value, like ip_address after login_name.

Julian Greenwood

About naming a computer automatically with the users login name. Keith Larson came up with an excellent idea for capturing the ip of a user to distinguish between user login in on multiple machines. What may also be helpful here is the MAC address as this will always be different, while you may sometimes have ip addresses the same.

Lee Andrews

This is in relation to the tip where you change the PC name to the users logon name by using the %logonname% variable and pasting it into the registry. Fine! Except that naming the PC after the logon name can cause problems with MS Networking, so this may not be such a good tip after all!

Ian Staines

A note about workstation naming. An additional contstraint of the host hame is that it cannot be a number. If the workstation name is a number, it is interpreted as an IP address instead of a name.

Ie: Workstation number 256 is interpreted as 0.0.1.0

WSName.exe

David Clarke sent this cool tool that might help with this chore.

Here's a tool called WSName that helps you change the name of workstations (both Netbios and Host) on Windows 9x and Win NT4. It is freeware. You can send comments to wsname@clarke.co.nz.

Here's how it works.

Command Line Switches

/H /? : Opens this document

/UNREG : Checks the "Unregister Workstation" function (if UNREG32.EXE is in the path)

/PG:<NametoCheck> : Post Ghost mode, see below for more details on Post Ghost

Post Ghost Mode

Post Ghost mode checks the name of the computer against the name passed with the /PG switch, if the names match the standard dialog is shown, otherwise the program terminates.

As workstations build via Ghost (or similar cloning tool) will have the same name the idea was to call WSName via a login script or NAL force run to remind the workstation builder to set the workstations name correctly.

Setting the Workstation Name

The workstation name is read using the "GetComputerName" API call The workstations new name is set using the "SetComputerName" API call.

Sadly both of these functions only concern themselves with the NetBIOS name, the TCPIP name (hostname) needs to be manipulated separately, I can't find an API that does this (and if you know of one please let me know) so we write directly to the registry, these keys differ between Windows NT and Windows 9x.

Windows NT:
HKLM\SYSTEM\CurrentControlSet\ Services\Tcpip\Parameters\

Windows 9x:
HKLM\SYSTEM\CurrentControlSet\ Services\VxD\MSTCP\

The workstation needs to be rebooted for the change to take effect.

Running UNREG32.EXE

During the program load, the SearchPath API call is used to search for UNREG32.EXE, if it is found then the "Unregister Workstation" tick box is enabled.

UNREG32.EXE removes the registry information about the workstation registration from HKLM\SOFTWARE\NOVELL\WORKSTATION MANAGER\IDENTIFICATION, it does not remove any objects from within the NDS.

UNREG32 is a component of Novell's ZENworks for Desktops.

The Workstation Name

WSName examines the new workstation name for validity based on the following:

Microsoft Support Document Q188997 details that valid NetBIOS computer names can be up to 15 alphanumeric characters with no blank spaces. The name must be unique on the network and can contain the following special characters:
! @ # $ % ^ & ( ) - _ ' { } . ~

The following characters are not allowed:
\ * + = | : ; " ? < > ,

Microsoft Support Document Q244739 suggests that it's not a good idea to start a computer name with a hypen (-).

Host names have slighly looser naming rules but since we want computer and host name to be the same, we'll work to the most restrictive.

Disclaimer

This software is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages arising from the use of this software.

Download

Download WSName.exe.



Additional Questions

If you know the answer to these, fire away.

Q: Richard Thomas
Regarding the tip posted on 7th June regarding NAL and programming the computer name to be a unique name.

I wish to make the DNS host name in the TCP/IP properties equivalent to the computer's computer name.

Can anyone suggest a simple variation on the original tip to facilitate this? I have tried a few times, but either it just doesn't work, or I am just screwing up the necessary syntax.

In the NAL package under macros, I am defining one called:

COMPUTER_NAME

in the value field for this macro, I have put the following:

[HKEY_LOCAL_MACHINE\System\CurrentControlSet\ control\ComputerName\ComputerName] "ComputerName"

In the registry settings area I am then assigning:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\ Services\VxD\MSTCP\HostName = %COMPUTER_NAME%

This does not work, so can anyone suggest an easy way to do this. Thanks very much.

A:Michel Py NEW

Richard Thomas wanted to make the DNS host name in the TCP/IP properties equivalent to the computer's computer name.

If the macro does not work, he can use the Script REGREAD command:

REGREAD "HKLM,System\CurrentControlSet\Control\ComputerName\ ComputerName,ComputerName"

SET COMPUTER_NAME="%99"

If you have any questions you may contact Michel at michel.py@hta-bi.bfh.ch


Q: This is in response to the name a computer the login name article. While it is a neat trick how would you map a drive to a computer that has a different name all the time?

A: Craig Wilson How do you automatically attach to a server whose name is constantly changing? First, I will assume it is an Win95/98/NT/2000 box, since it is unlikely you will be frequently renaming a Novell server. There are two common ways to attach to a server using MS Networking.
  1. Via an UNC Path - \\PCNAME\SHARENAME
  2. Via an IP address - \\123.123.123.1234\SHARENAME

There are a number of ways to achieve this information.

  • Install Workstation Manager on the Desired Machine. Make sure to keep the name of the workstation object constant, even though you keep renaming the computer.
    • %.FMPC11IZ.WSOBJECTS.ITHOWTO;ZEN:INV IP Address% returns the machine's IP address
    • %.FMPC11IZ.WSOBJECTS.ITHOWTO;WM:NAME Computer% returns the Netbios Name of the machine.

    Both of these should remain valid in a dynamic environment in which the IP address and the machine name of the target machine are constantly changing.

    In the login script place one of the two lines

    • NET USE K: \\%.FMPC11IZ.WSOBJECTS.ITHOWTO;ZEN:INV IP Address%\SHARENAME
    • NET USE K: \\%.FMPC11IZ.WSOBJECTS.ITHOWTO;WM:NAME Computer%\SHARENAME
  • Create an application object, assign it to the desired MS Server, and set it to force run and distribute always.

    In the Launch script of the app object, place the following lines:

    REGREAD "HKLM,System\CurrentControlSet\ Control\ComputerName\ ActiveComputerName,ComputerName"

    DOS SET PCNAME="%99"

    In the Text Section of the App object create a text file on a central Novell server named

    "EXTRAMAP.TXT"

    In this file, add the line NET USE K: \\"%99"\sharename

    In your main login script add the line - Include EXTRAMAP.TXT

    Craig is the senior consultant at WWW.ITHOWTO.COM

    NEW A: Mark Capelle

    This is in response to the question regarding mapping a drive to a machine that has a name that changes constantly. Why not give that machine a static IP address and map the drive to the IP address?

    NEW A: Paul Gilpin

    If the machine has a static IP address, use this instead of the machine name.


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

  • © 2014 Novell