Change Name then join Domain VBS

Ok this script changes the computer name to the service tag from bios (Dell machines) im trying to get it to join domain after but its not doing it. It completes with restart etc but it jsut doesnt seem to join domain. There are no errors that it reports. Anyone got any ideas? If i manually try join domain using the credentials in the script it works fine.
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
  strSN = objSMBIOS.SerialNumber
  If strSN <> "" Then exit For
Next 
 
Set ws = WScript.CreateObject("WScript.Shell")
value1 = "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\"
value2 = "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\ParameterS\"
ws.RegWrite value1 & "ComputerName", strSN
ws.RegWrite value2 & "NV Hostname", strSN
 
Const JOIN_DOMAIN             = 1
Const ACCT_CREATE             = 2
Const ACCT_DELETE             = 4
Const DOMAIN_JOIN_IF_JOINED   = 32
Const JOIN_UNSECURE           = 64
Const DEFERRED_SPN_SET        = 256
Const INSTALL_INVOCATION      = 262144
strDomain   = "DOMAINNAMEHERE"
strPassword = "PASSWORDHERE"
strUser     = "USERNAMEHERE"
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objComputer = _
    GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
    strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" _
    & strComputer & "'")
ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
    strPassword, _
    strDomain & "\" & strUser, _
    NULL, _
    JOIN_DOMAIN)
 
wshshell.run "shutdown /r" 
Set WSHShell = Nothing
WScript.Quit(0)

Open in new window

k3eperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PberSolutions ArchitectCommented:
Change this:
ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
    strPassword, _
    strDomain & "\" & strUser, _
    NULL, _
    JOIN_DOMAIN)
 to this:
ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
    strPassword, _
    strDomain & "\" & strUser, _
    NULL, _
    JOIN_DOMAIN+ACCT_CREATE)
 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
yehudahaCommented:
change

ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
    strPassword, _
    strDomain & "\" & strUser, _
    NULL, _
    JOIN_DOMAIN)

to

ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
   strPassword, strDomain & "\" & strUser, NULL, _
       JOIN_DOMAIN + ACCT_CREATE)
0
PberSolutions ArchitectCommented:
See this as well.  It's pretty much the exact method you are using, but at MSDN they too do the  JOIN_DOMAIN+ACCT_CREATE
http://msdn.microsoft.com/en-us/library/aa392154(VS.85).aspx 
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

yehudahaCommented:
Pber we are twins !!! :-)

sorry didn't refresh the page
0
PberSolutions ArchitectCommented:
(:
0
k3eperAuthor Commented:
Great thanks works like a charm
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.