A customer, time ago,  asked me more clarifications about how to join his scripted installed Windows 7 x64 to the domain and change the name to it as well in one go so I started to play a bit around with WSNAME and this is the solution that I suggested:

  1. Create a Scripted installation where you join to the domain:
  2. Create a new postinstallation task “Naming Rule” type
  3. upload to it your namedb.dat file with the MAC addresses and hostnames
  4. amend the command line in this way:
    wsname.exe /RDF:namedb.dat /DFK:$MAC /EXCLUDEADAPTERS[WIRELESS WIFI WLAN BLUETOOTH PPP VMWARE IPSEC CENTRINO] /rcid /user:kace\administrator /pass:pw
  5. add the naming rule postinstallation task as the last task of your scripted installation

NOTE: A reboot is needed so you may create a further post-installation task with a reboot command and add it as last action immediately after the name change task.

If you do not want to specify the password in clear text in the WSNAME command line you can use a masked password as stated in the wsname-documentation:

eg: wsname /n:mynewname /rcid /user:mydomain\administrator /passm:H#FG$RFGHYD4G6Hj

To get the masked password use the /MASKPASSWORD switch

eg: wsname /MASKPASSWORD /PASS:secret