1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| On Error Resume Next
Const ForReading = 1, ForWriting = 2
Set WshShell = WScript.CreateObject("WScript.Shell")
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("C:\Documents and Settings\Desktop\ecr.txt", ForWriting,true)
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard in colNetCards
f.write(objNetCard.IPAddress(0).StartWith("192.168.0"))
If (objNetCard.IPAddress(0).StartWith("192.168.0") OR objNetCard.IPAddress(0).StartWith("192.168.3")) Then
strPrimaryServer = "192.168.0.9"
strSecondaryServer = ""
objNetCard.SetWINSServer strPrimaryServer, strSecondaryServer
End If
Next |