Does anyone out there know if it is posisble to have a post install task that prompts you for computer name, then renames the computer to the name that was input and then asked for the name of the Active Directory domain to join and then joins that domain?

I'm not a programmer at all and have no experience with anything other than batch files so any help would be appreciated.

0 Comments   [ + ] Show Comments


Please log in to comment

Community Chosen Answer



I use the join_domain.vbs script supplied by kace to join the domain

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("")
    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 11/21/2013 by: SMal.tmcc
Red Belt

  • cscript.exe -b c:\windows\w2d\join_domain.vbs installer XXXXXX
    • Thank you for that I will test it out. I am kind of thinking about leaving the password in clear text. I'm guessing you have a service account setup that you use to join the domain and not a domain admin account?
      • yes that user is to join the domain. when you use this as a post script, the only people who can see the password are ones who can log onto the kbox to read it.
        the line above is one of my post image commands I call the script with the domain, user, & password after the script to autojoin

        I still use the get/set script from here to name the machines when I want the machines to keep the current name.
Please log in to comment



The GetComputerName preinstall task and the SetComputerName postinstall task will accomplish the first part of what you're requesting.  There are a lot of vbs scripts for joining a computer to the domain, not sure on the prompting part though.

Answered 11/21/2013 by: nheyne
Red Belt

  • Does the GetComputerName task ask you to enter what you want the name to be? I am deploying to brand new out of the box desktops, So the task would have to prompt you for a name.
    • Yes there is a /dialog option that will show what the current name is, and let you either accept it or enter a new name.
      • ok thank you. And just to be sure we are talking about the same thing, we are talking about the preloaded script that is on the K2000 right out of the box.
      • It looks like we where talking about different thing. I was able to find on the Kace script site, getcomputername.exe and getcomputernamex64.exe I followed the instructions and setup my tasks now to test. Thanks for pointing me in the right direction.
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