Hello,
I have this vbs script that's suppose to join the windows 7 to domain image at first boot. It's able to rename but at join domain part it fails and comes back with Join domain Failed. Error = 1332 Exiting script. Prior to syspreping the image, this script words perfectly fine but after sysprep it runs at first logon under SetupComplete.CMD in C:\windows\setup\scripts\setupcomplete.cmd I tell this cmd to run start c:\windows\setup\scripts\joindomain.vbs
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
Dim sCmpName
Dim sUser, sPassword, sDomain, sOU
sUser = "test"
sPassword = "test"
sDomain = "test"
sCmpName = InputBox("Enter the new computer name:", "Computer Name")
If sCmpName = "" Then
Wscript.Echo "Exiting script."
Wscript.Quit
End If
Dim oWMI, oCmp, oOS, sReturn
Set oWMI = GetObject("winmgmts:\\.\root\cimv2")
For Each oCmp in oWMI.InstancesOf("Win32_ComputerSystem")
sReturn = oCmp.Rename(sCmpName)
If sReturn <> 0 Then
Wscript.Echo "Rename failed. Error = " & sReturn & _
vbcrlf & "Exiting script."
Else
Wscript.Echo "Rename successful."
sReturn = oCmp.JoinDomainOrWorkgroup(sDomain, sPassword, _
sDomain & "\" & sUser, sOU, JOIN_DOMAIN)
If sReturn <> 0 Then
Wscript.Echo "Join domain failed. Error = " & sReturn & _
vbcrlf & "Exiting script."
Else
Wscript.Echo "Join domain successful."
End If
Wscript.Echo "Rebooting computer..."
Dim oShell
Set oShell = CreateObject("Wscript.Shell")
sReturn = oShell.Run("%comspec% /c shutdown -r -t 0 -f")
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile WScript.ScriptFullName
Set objFSO = Nothing
End If
Next
Open in new window