Monday, September 6, 2010

How to change DNS suffixes remotely with VBS


In Windows Vista or XP on a network domain it's important to resolve the DNS names and suffixes when you want to get to different network resources. This vbs will allow you to change those TCP/IP settings programmatic, especially if you need to change your Domain information on the fly!
 
Const HKEY_LOCAL_MACHINE = &H80000002

Dim strInstall1, strInstall2, strInstall3, strInstall4, yInput, xInput, vUsername, vPassword
Dim objFSO, objFileCopy, objGuyFile
Dim strFilePath, strDestination
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
Dim WshNetwork

Set WshShell = CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("PROCESS")

strComputer = "."
nCounter = 0
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

  Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
            strComputer & "\root\default:StdRegProv")
            strKeyPath = "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters"

            strEntryName = "SyncDomainWithMembership"
            strValue = "000000000"
            objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strEntryName, strValue

            strEntryName = "Domain"
            strValue = "ds.apollo.com"
            objReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strEntryName, strValue

            strEntryName = "SearchList"
            strValue = "ds.apollo.com,apollo.com"
            objReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strEntryName, strValue

            strEntryName = "NV Domain"
            strValue = "ds.apollo.com"
            objReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strEntryName, strValue

WScript.Quit

No comments:

Post a Comment

Generating "Always On Top" NSWindow in macOS across all detected displays

Also: Using UIKit & Cocoa Frameworks using Objective-C In m acOS or OS X , written in either Objective-C or Swift  Langues, you m...