Here's my unattend.xml and below the joindomain.vbs
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="generalize">
<component name="Microsoft-Windows-Security-SPP" processorArchitecture="amd64" publicKeyToken="blabla" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SkipRearm>1</SkipRearm>
</component>
</settings>
<settings pass="specialize">
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="blabla" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RunSynchronous>
<RunSynchronousCommand wcm:action="add">
<Order>1</Order>
<Path>net user administrator /active:no</Path>
</RunSynchronousCommand>
</RunSynchronous>
</component>
<component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="blabla" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SkipAutoActivation>true</SkipAutoActivation>
</component>
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="blabla" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CopyProfile>false</CopyProfile>
<ShowWindowsLive>false</ShowWindowsLive>
<TimeZone>Romance Standard Time</TimeZone>
</component>
</settings>
<settings pass="oobeSystem">
<component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="blabla" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<UILanguage>en-US</UILanguage>
<SystemLocale>nb-NO</SystemLocale>
<UserLocale>nb-NO</UserLocale>
<InputLocale>nb-NO</InputLocale>
</component>
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="blabla" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<AutoLogon>
<Password>
<Value>blabla==</Value>
<PlainText>false</PlainText>
</Password>
<Enabled>true</Enabled>
<LogonCount>1</LogonCount>
<Username>admin</Username>
</AutoLogon>
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<CommandLine>cscript //b c:\windows\system32\slmgr.vbs /ipk xxxx-xxxx-xxxx-xxxx-xxxx</CommandLine>
<Order>1</Order>
<RequiresUserInput>false</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cscript //b c:\windows\system32\slmgr.vbs /ato</CommandLine>
<Order>2</Order>
<RequiresUserInput>false</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>c:\temp\scripts\JoinDomain.vbs</CommandLine>
<Order>3</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
</FirstLogonCommands>
<OOBE>
<HideEULAPage>true</HideEULAPage>
<NetworkLocation>Work</NetworkLocation>
<ProtectYourPC>1</ProtectYourPC>
</OOBE>
<UserAccounts>
<AdministratorPassword>
<Value>blabla</Value>
<PlainText>false</PlainText>
</AdministratorPassword>
<LocalAccounts>
<LocalAccount wcm:action="add">
<Password>
<Value>blabla==</Value>
<PlainText>false</PlainText>
</Password>
<Description>Local Administrator</Description>
<Group>Administrators</Group>
<Name>Admin</Name>
<DisplayName>Admin</DisplayName>
</LocalAccount>
</LocalAccounts>
</UserAccounts>
<RegisteredOrganization>RegisteredOrganization</RegisteredOrganization>
<RegisteredOwner>NO</RegisteredOwner>
</component>
</settings>
<cpifflineImage cpi:source="catalog:c:/sw_dvd5_win_pro_7w_sp1_64bit_english_-2_mlf_x17-59279/sources/install_windows 7 professional.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>
----------------------------------------------------------------
Call DoSomething
Sub DoSomething
Dim strPassword
Dim strDomain
Dim strUser
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
Const ACCT_DELETE = 4
Const WIN9X_UPGRADE = 16
Const DOMAIN_JOIN_IF_JOINED = 32
Const JOIN_UNSECURE = 64
Const MACHINE_PASSWORD_PASSED = 128
Const DEFERRED_SPN_SET = 256
Const INSTALL_INVOCATION = 262144
strDomain = "domain.name"
strUser = "uid"
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonat e}!\\" & strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")
Do
strPassword = InputBox("Enter password to join domain:", "Join to Domain", "password")
If strPassword = "" Then Exit Sub
ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, strPassword, strDomain & "\" & strUser, NULL, JOIN_DOMAIN + ACCT_CREATE)
If ReturnValue = 1326 Then
MsgBox "Logon failure: unknown username or bad password."
End If
If ReturnValue <> 1326 Then Exit Do
Loop
If ReturnValue = 5 Then
MsgBox "Access is denied. Run from an elevated command prompt."
Exit Sub
ElseIf ReturnValue = 87 Then
MsgBox "The parameter is incorrect."
Exit Sub
ElseIf ReturnValue = 110 Then
MsgBox "The system cannot open the specified object."
Exit Sub
ElseIf ReturnValue = 1323 Then
MsgBox "Unable to update password."
Exit Sub
ElseIf ReturnValue = 1355 Then
MsgBox "The specified domain does not exist or could not be contacted."
Exit Sub
ElseIf ReturnValue = 2224 Then
MsgBox "The account already exists."
Exit Sub
ElseIf ReturnValue = 2691 Then
MsgBox "The machine is already joined to the domain."
Exit Sub
ElseIf ReturnValue = 2692 Then
MsgBox "The machine is not currently joined to the domain."
Exit Sub
End If
If ReturnValue = 0 Then
If MsgBox("Domain joined successfully. Restart machine?", vbQuestion + vbYesNo) = vbYes Then
Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
For Each OpSys in OpSysSet
OpSys.Reboot()
Next
Else
'Just quit
End If
End If
End Sub