You can do this using WMI in the .NET Framework.
Add a reference to System.Management and System.Management.Instrumentation and import the namespaces. Then...
vb.net Code:
Dim managementObj as new ManagementObject("root\\CIMV2", "Win32_ComputerSystem.Name='" & _
Environment.MachineName & "'", Nothing)
Dim parameter as ManagementBaseObject = managementObj.GetMethodParameters("Rename") _
parameter["Name"] = "NEWCOMPUTERNAMEHERE"
Dim outParams as ManagementBaseObject = managementObj.InvokeMethod("Rename", inParams, null)
This should rename the computer. Does this work for you?
Joining a new domain is a different story. The computer name change will not take affect until the machine is rebooted.