Hi,
I'm not great with vb scripting but I know it can be done that way if you can program it.
Instead, as I only know batch commands I use a program called wsname.exe it has command line switches:
Workstation Name Changer
With this you can read mac addresses and corresponding computer names from a text file and if the current machines mac address matches one in the list, the wsname program renames the hostname to the corresponding name you put in the list.
You'll need to reboot the machine too for it to take effect. so you can use the shutdown command to do that in your batch file:
shutdown.exe /f /r /t: 5 /c "DONT PANIC! Restarting for auto config settings to take effect."
The other program I use to add the workstation to the ad domain is NETDOM.exe from microsoft.
It can be downloaded as part of the windows xp support tools pack:
WindowsXP-KB838079-SupportTools-ENU <-- that's what you're looking for. Use 7zip to extract the support.cab contents into a folder and you'll find netdom.exe in the list of files. Check its command line switches for usage.
I'm sure all of this stuff can be done these days with power shell but I haven't had time to learn it yet. I have however seen it in action and it is EXTREMELY powerful for active directory manipulation in the right hands from a command prompt.
Netdom requires that the workstation service is up and running before it will work correctly. This required me to run the sleep.exe program, also from Microsoft to pause the batch file for 15 seconds to ensure the workstation service was up and running before proceeding. Sleep can be downloaded as part of the windows resource kit tools pack rktools.exe its inside a cab file called Cabs.winrk.cab
Netdom will also fail if the machine already has an existing account on the domain, so they must be deleted from their OU's before running netdom in a batch file.
Look at wsname, netdom and sleep. This is all you need to rename the machine and add it to the domain automatically using 2x batch files in the startup folder (not runonce) and 1 or 2 reboots.
Hope that helps.
PS. Machine accounts sometimes take a while to appear in the ad users and computers browser. They don't all show up at once.