I am using a join domain and rename post install task from this KACE article:

http://www.kace.com/support/resources/kb/article/How-to-rename-a-computer-and-join-it-to-a-Windows-domain-Image-Deployment

But the join_domain.vbs script sets a static DNS server which it does not remove and therefore causes issues when connecting to a different network (The DNS server address by the way is pulled from the JoinDomain.bat script downloaded in the same package (explained in the KACE article).

My VB scripting is rubbish so does anyone know how I can change the script syntax to pull a DNS server address from DHCP instead of setting it statically?

Syntax:

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

If WScript.Arguments.Count < 3 or WScript.Arguments.Count > 4 Then
WScript.Quit
Else
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, _
JOIN_DOMAIN+ACCT_CREATE)
Answer Summary:
Added the following command to the end of the script: netsh interface ip set dns "Local Area Connection" source=dhcp
Cancel
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Community Chosen Answer

3

I have managed to accomplish this by adding the following command to the end of my JoinDomain.bat script (not that anybody seems interested)

netsh interface ip set dns "Local Area Connection" source=dhcp

Answered 04/26/2012 by: LiamSinton
Senior Yellow Belt

  • I'm interested and thanks for the help. I had the same issue
  • Perfect... thank you... that worked
  • Thank you! I've been having this issue also!
Please log in to comment

Answers

0

I've been having the same problem. Thanks a lot for the post.

Answered 10/22/2012 by: rzielinski
White Belt

Please log in to comment
Answer this question or Comment on this question for clarity

Share