Hello,
I had gotten some great help here from tsuji an a DNS script which I might add works great. However my bosses have thrown another wrench into the gears. I am working with a mixed environment of NT4, Win2k and WinXP. I need this DNS script to run in an admin elevated state, becuase not all uses are local admins. I also have another hurdle with this. I need to not show the admin password becuase this would then degrade the security of the network. Below is a copy of the DNS script I am using. Any and all help would be greatly appreciated.
dim arrDNSServers()
aNewEntries=array("123.123.123.123")
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\"& strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each objAdapter in colAdapters
if (not objAdapter.DHCPEnabled) then
idim=0
for i=0 to ubound(aNewEntries)
bDuplicate=false
if i=0 then
redim arrDNSServers(0)
arrDNSServers(i)=aNewEntries(i)
else
for j=0 to i-1
if aNewEntries(i)=arrDNSServers(j) then
bFound=true : exit for
end if
next
if not bDuplicate then
redim preserve arrDNSServers(ubound(arrDNSServers)+1)
arrDNSServers(ubound(arrDNSServers))=aNewEntries(i)
end if
end if
next
if (not IsNull(objAdapter.DNSServerSearchOrder)) then
for i = 0 To UBound(objAdapter.DNSServerSearchOrder)
' WScript.Echo " " & objAdapter.DNSServerSearchOrder(i)
bDuplicate=false
for j=0 to ubound(arrDNSServers)
If objAdapter.DNSServerSearchOrder(i)=arrDNSServers(j) then
bDuplicate=true : exit for
end if
next
if not bDuplicate then
redim preserve arrDNSServers(ubound(arrDNSServers)+1)
arrDNSServers(ubound(arrDNSServers))=objAdapter.DNSServerSearchOrder(i)
end if
next
end if
objAdapter.SetDNSServerSearchOrder(arrDNSServers)
erase arrDNSServers
end if
Next
I had gotten some great help here from tsuji an a DNS script which I might add works great. However my bosses have thrown another wrench into the gears. I am working with a mixed environment of NT4, Win2k and WinXP. I need this DNS script to run in an admin elevated state, becuase not all uses are local admins. I also have another hurdle with this. I need to not show the admin password becuase this would then degrade the security of the network. Below is a copy of the DNS script I am using. Any and all help would be greatly appreciated.
dim arrDNSServers()
aNewEntries=array("123.123.123.123")
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\"& strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each objAdapter in colAdapters
if (not objAdapter.DHCPEnabled) then
idim=0
for i=0 to ubound(aNewEntries)
bDuplicate=false
if i=0 then
redim arrDNSServers(0)
arrDNSServers(i)=aNewEntries(i)
else
for j=0 to i-1
if aNewEntries(i)=arrDNSServers(j) then
bFound=true : exit for
end if
next
if not bDuplicate then
redim preserve arrDNSServers(ubound(arrDNSServers)+1)
arrDNSServers(ubound(arrDNSServers))=aNewEntries(i)
end if
end if
next
if (not IsNull(objAdapter.DNSServerSearchOrder)) then
for i = 0 To UBound(objAdapter.DNSServerSearchOrder)
' WScript.Echo " " & objAdapter.DNSServerSearchOrder(i)
bDuplicate=false
for j=0 to ubound(arrDNSServers)
If objAdapter.DNSServerSearchOrder(i)=arrDNSServers(j) then
bDuplicate=true : exit for
end if
next
if not bDuplicate then
redim preserve arrDNSServers(ubound(arrDNSServers)+1)
arrDNSServers(ubound(arrDNSServers))=objAdapter.DNSServerSearchOrder(i)
end if
next
end if
objAdapter.SetDNSServerSearchOrder(arrDNSServers)
erase arrDNSServers
end if
Next