ComputerNameSet

Sets the name associated with the local computer.

Syntax:

ComputerNameSet( computername, format )

Parameters:

(s) computername: new computer name

(i) format: specifies what value to set. See below.

Returns:

(i) result @TRUE on success and @FALSE on failure.

 

In Windows 95/98/ME, "format" must be 0. In Windows NT and newer, "format" can be one of the following values:

Value

Meaning

0

In Windows 95/98/ME, sets the NetBIOS name. In Windows NT and newer, same as 105 (below).

104

Sets the NetBIOS name. The name cannot exceed 15 characters. Warning: Using this option to set the NetBIOS name breaks the convention of interdependent NetBIOS and DNS names. Applications that use the DnsHostnameToComputerName function to derive the NetBIOS name from the first label of the DNS name will fail if this convention is broken.

105

Sets the NetBIOS and the Computer Name (the first label of the full DNS name). If the name exceeds 15 characters, the NetBIOS name is truncated to 15 characters.

106

Sets the primary DNS suffix of the computer.

 

Changes do not take effect until the computer is restarted.

If the computer is a member of the domain: use the wntUserRename() function in the NT extender to rename the machine account. Remember that machine accounts are hidden [e.g. they have a trailing "$" in the name] and they are are always in lowercase. Remember that you must have appropriate rights in order to set the computer name and to rename the computer's machine account in the domain.

Windows Vista/2008 and newer: This function may require an Administrator level account

Example:

result = ComputerNameSet( "OZWEEGO", 0 )
Message( "ComputerNameSet", "Set the NetBIOS & Computer name of the local computer.")

See Also:

ComputerNameGet