We help IT Professionals succeed at work.

VBS script error 1332

Samad Abdul
Samad Abdul asked
on
211 Views
Last Modified: 2018-08-03
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

Shaun VermaakSenior Consultant
CERTIFIED EXPERT
Awarded 2017
Distinguished Expert 2019

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

Open in new window

This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
MikeIT Professional
CERTIFIED EXPERT

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