Windows Scripting BLOG

Due to limited time working on this project this place is not intended to people who are new to scripting but much more for people who are already familiar with the VBS/WMI syntax.

Donnerstag, 17. Mai 2007

Setting Network config to DHCP

On Error Resume NextIN_FILE = Wscript.Arguments(0)
Const PRO_READ = 1Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(IN_FILE, PRO_READ)
strComputers = objFile.ReadAllobjFile.ClosearrComputers = Split(strComputers, vbCrLf)
For Each strComputer In arrComputers
Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery _ ("Select * from Win32_NetworkAdapterConfiguration")
For Each objComputer in colComputersif ObjComputer.EnableDHCP = false then errRec = ObjComputer.EnableDHCP()
Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
errRec = ObjComputer.SetDNSServerSearchOrder() errRec = ObjComputer.SetWINSServer("", "")
WScript.Echo "Changed to DHCP Config at: " & strComputer else
end if
if ObjComputer.EnableDHCP = true then WScript.Echo "DHCP already configured at Computer: " & strComputer
else
end if
Next
Next
'created by Julian Ruf

Keine Kommentare: