Nice one Bilou_Gateux
Beware however that this will
not work if run at T13 ... Although WMI responds to calls, anything that I tried to set using it, resulted in an error ... The other thing you can do is call the SetComputerNameEx function from kernel32.dll and change ComputerNamePhysicalNetBIOS and ComputerNamePhysicalDnsHostname. A nice VB example for achieving this can be found
here. Or you could use
this function in XP.
All the above will work on a standalone workstation. You would have to call some AD function to change the computer name if it belongs to a domain. A nice tool to do this is
netdom.exe.
For a standalone PC (2k/XP/2k3) I have been using
compname.exe up until now. It has some nice features:
Quote
Displays SMBIOS information and changes/displays the computer name.
COMPNAME [/c name | /d [template]| /s]
/c[hange] Changes the computer name to the one specified.
/d[isplay] Displays the computer name.
/s[mbios] Displays the serial number information from SMBIOS.
name New computer name. Only valid with the /c option.
This may contain macros; see below.
template When used in conjuction with /d, displays the evaluated name.
Templates will normally contain macros; see below.
The following macros are valid in the name or template.
?s = System serial number. ?c = Chassis serial number.
?b = Mainboard serial number.
?a = The first populated number from system, chassis and mainboard numbers.
?u = System UUID ?U = Fake UUID (24 zeros plus MAC).
?G = If System UUID is FFFF... or 0000... or null it uses ?U, otherwise ?u.
?i, ?j, ?k, ?l = 1st, 2nd, 3rd, 4th octets of IP (decimal).
?I, ?J, ?K, ?L = 1st, 2nd, 3rd, 4th octets of IP (hex).
?d = Hostname found by reverse DNS lookup of IP address.
?m = First MAC address. ?e = Existing NetBIOS computer name.
?D = day ?M = month ?Y = year
?1, ?2, ?3, ..., ?0 = 1, 2, 3, ..., 10 random alphanumeric characters.
Examples:
COMPNAME /d Displays the NetBIOS computer name.
COMPNAME /d ?s Displays the system serial number.
COMPNAME /s Displays system summary information.
COMPNAME /c jupiter Changes computer name to "jupiter".
COMPNAME /c acme-?s Changes computer name to "acme-ABCDEF" where
ABCDEF is the system serial number.
Notes:
* You can simply replace a /c switch with a /d switch to check the name.
* If the name (after macro expansion) is longer than 15 characters,
then the NetBIOS name will be truncated, but the DNS name (on Windows
2000 and above) will be the full length. This may break some applications.
* The following characters (and spaces) are invalid and removed automatically:
\ * + = | : ; " ? < > ,
* The _ character gets translated to - to avoid DNS name problems.
* This program does not rename the computer's domain account.
----------------------------------------------------------------------------
All of the above you can get with WMI. If however you want to rename the computer say at T13 it might be a good idea to use thsi tool

)
CF