For the past few months we've been using getcomputername.exe as a Pre-Install Task, and setcomputername.exe as a Mid-Level Install Task, to name our machines. We've been happy with it as our naming convention is varied, e.g. it doesn't work off machine hardware like a serial number, and we like having a prompt.

We're now working on binding the machine to Active Directory but have had little success. So far we've tried using the join_domain.vbs that's already loaded onto the K2000. I've edited the Command Line options to input our domain, username, password and DNS server. For some reason the scripted installs run as normal but there's no binding occuring. I've checked obvious things like is the machine in AD etc. Am i meant to be editing this join_domain.vbs file at all? Any ideas?

Thanks for your help!

Answer Summary:
0 Comments   [ + ] Show Comments


  • This content is currently hidden from public view.
    Reason: Removed by member request
    For more information, visit our FAQ's.
Please log in to comment



When you are editing the Join Domain Postinstall task, are you removing the <> from the command line? 

Answered 06/17/2013 by: andrew_lubchansky
Black Belt

  • I thought you might have been onto something there as i did leave the <> in. Unfortunately it's still not binding. I have it running as the last post-installation task on our Windows XP scripted installs. Will try Windows 7 and see if there is any difference due to auto-login on our admin account...
Please log in to comment

do you have other post installation task? Are they working fine?
Remember that if you are deploying an image of an OS and if the OS is not ''sysprepped'' the post installation actions are not going to be executed.
Have you tried, as a test, to execute the script manually on a machine that is not joined to the domain yet to see if it works or not??
You can invoke it in this way from command line:
cscript join_domain.vbs "thedomain" "Administrator" "thepassword"
Do not specify the user in the form domain\user but only specify the user name of a domain user that is able to add machines to the domain.
Another good idea might be the one to redirect the output of the script in the post install action to a file to see if there is some output there;
You can try to modify the postinstallation action in this way: (example)
join_domain.vbs "mydomain" "admin" "mypass" > c:\logscript.txt
Kind regards,
Marco - StockTrader :-)

Answered 06/17/2013 by: StockTrader
Red Belt

Please log in to comment

For images when I sysprep I do not put the machine name in the answer file.  When I image I use the get and apply computer name scripts if I want to keep the name, If I do not use the 2 scripts it prompts for a name.  during post the machines join to the domain whether I named them or the scripts named them.  I copied the join domain script into my images so I call it from the local drive.

start /wait cscript.exe c:\windows\w2d\join_domain.vbs tmccacad.tmcc.edu DomainUserWithJionRights Password.

this is the vb script (it is unaltered)


Const JOIN_DOMAIN             = 1
Const ACCT_CREATE             = 2
Const ACCT_DELETE             = 4
Const WIN9X_UPGRADE           = 16
Const JOIN_UNSECURE           = 64
Const DEFERRED_SPN_SET        = 256
Const INSTALL_INVOCATION      = 262144

If WScript.Arguments.Count < 3 or WScript.Arguments.Count > 4 Then
  strDomain   = WScript.Arguments.Item(0)
  strUser = WScript.Arguments.Item(1)
  strPassword = WScript.Arguments.Item(2)

'set DNS IP address
  If WScript.Arguments.Count = 4 Then
    strDNSIP = WScript.Arguments.Item(3)
    Set objShell = CreateObject("WScript.shell")
    objShell.Run "netsh int ip set dns  ""local area connection"" static "& _
                  strDNSIP &" primary",0,0
  End If

End If

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, _




Answered 06/17/2013 by: SMal.tmcc
Red Belt

  • Thank you all for your help. I've managed to get it working by editing the VBS script to include a prompt for username, password and domain, and remove the automatic adding of the account to AD as our structure is too complicated, therefore we add the machine in manually. I've set it to run as the last post-install task without any switches. In case anyone is interested, here is our script:

    Const JOIN_DOMAIN = 1
    Const ACCT_CREATE = 2
    Const ACCT_DELETE = 4
    Const WIN9X_UPGRADE = 16
    Const JOIN_UNSECURE = 64
    Const DEFERRED_SPN_SET = 256
    Const INSTALL_INVOCATION = 262144

    ' Prompt for credentials.
    strDomain = InputBox(&quot;Enter name of domain&quot;)
    strUser = InputBox(&quot;Enter account name to use&quot;)
    strPassword = InputBox(&quot;Enter the account password&quot;)

    ' Retrieve NetBIOS name of local computer.
    Set objNetwork = CreateObject(&quot;WScript.Network&quot;)
    strComputer = objNetwork.ComputerName

    Set objComputer = GetObject(&quot;winmgmts:&quot; _
    &amp; &quot;{impersonationLevel=Impersonate,authenticationLevel=Pkt}!\\&quot; &amp; _
    strComputer &amp; &quot;\root\cimv2:Win32_ComputerSystem.Name='&quot; &amp; _
    strComputer &amp; &quot;'&quot;)

    lngReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
    strPassword, strDomain &amp; &quot;\&quot; &amp; strUser, strOU, _

    Wscript.Echo &quot;ReturnValue = &quot; &amp; CStr(lngReturnValue)

    Select Case lngReturnValue
    ' Some return code values (added 04/05/2010).
    Case 0
    Wscript.Echo &quot;Success joining computer to the domain!&quot;
    Case 5
    Wscript.Echo &quot;Access is denied&quot;
    Case 87
    Wscript.Echo &quot;The parameter is incorrect&quot;
    Case 110
    Wscript.Echo &quot;The system cannot open the specified object&quot;
    Case 1323
    Wscript.Echo &quot;Unable to update the password&quot;
    Case 1326
    Wscript.Echo &quot;Logon failure: unknown username or bad password&quot;
    Case 1355
    Wscript.Echo &quot;The specified domain either does not exist or could not be contacted&quot;
    Case 2224
    Wscript.Echo &quot;The account already exists&quot;
    Case 2691
    Wscript.Echo &quot;The machine is already joined to the domain&quot;
    Case 2692
    Wscript.Echo &quot;The machine is not currently joined to a domain&quot;
    Case Else
    Wscript.Echo &quot;Unknown error&quot;
    End Select
    • We create our machines ahead of time in AD, less hassles.
Please log in to comment
Answer this question or Comment on this question for clarity
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja