VBS script error 1332

Samad Abdul
Samad Abdul used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Shaun VermaakTechnical Specialist
Awarded 2017
Distinguished Expert 2018

Commented:
Please post content of this file
C:\Windows\Debug\NetSetup.log

Open in new window

Thank you I have resolved the issue. Turns out that when the computer was renaming, it wasn't being changed until after reboot, so I changed the answer file and had it so I change the computer name before it logs into windows for the first time. It asks for rename still but it works now.
MikeIT Professional

Commented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: Samad Abdul (https:#a42068789)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

FireRunt
Experts-Exchange Cleanup Volunteer

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial