Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to run a script as local admin...

Status
Not open for further replies.

blaster99

MIS
Aug 11, 2004
17
US
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'd dump this script into an ASP page and set the web site to use the admin ID instead of the IUSER_MACHINE ID.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
OK,

This sounds all well and good, but I have never worked with ASP. So I really don't know where to begin and have even less time to fumble my way through it. Thank you, I will look into it when I have a free moment. Any other ideas would also be greatly appreciated.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top