Re: Change DNS on NT 4.0
From: Jeff Cochran (jcochran.nospam_at_naplesgov.com)
Date: 04/29/04
- Next message: Viatcheslav V. Vassiliev: "Re: Server Networking Information"
- Previous message: M: "Server Networking Information"
- In reply to: anonymous_at_discussions.microsoft.com: "Re: Change DNS on NT 4.0"
- Next in thread: anonymous_at_discussions.microsoft.com: "Re: Change DNS on NT 4.0"
- Reply: anonymous_at_discussions.microsoft.com: "Re: Change DNS on NT 4.0"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 29 Apr 2004 18:47:03 GMT
On Thu, 29 Apr 2004 08:14:24 -0700,
<anonymous@discussions.microsoft.com> wrote:
>If I have DNS entries on my NT workstation it just
>removes them but does not add my new ones in my text file.
Might look at:
http://www.microsoft.com/technet/community/scriptcenter/network/scnet116.mspx
Jeff
>>-----Original Message-----
>>Yes-
>>
>>I am logged in as the local admin on the box. The
>>machine is just in a workgroup and is not part of my
>>domain. I want to be able to change the DNS setting no
>>matter who is logged in.
>>>-----Original Message-----
>>>On Wed, 28 Apr 2004 09:21:53 -0700,
>>><anonymous@discussions.microsoft.com> wrote:
>>>
>>>>I get the following Error:
>>>>
>>>>Script: myscript.vbs
>>>>Line: 41
>>>>Char: 4
>>>>Error: Permission denied: 'GetObject'
>>>>Code: 800A0046
>>>>Source: Microsoft VBScript runtimer error
>>>
>>>Logged in as a local admin?
>>>
>>>Might look at:
>>>
>>>http://support.microsoft.com/default.aspx?scid=kb;EN-
>>US;q251361
>>>http://www.iisfaq.com/default.aspx?View=A323&P=109
>>>
>>>Jeff
>>>
>>>>I have installed WMI on my NT workstation from
>>>>http://www.microsoft.com/downloads/release.asp?
>>>>ReleaseID=18490
>>>>
>>>>
>>>>Here is the script I am using. I have a text file
>that
>>>>looks like this.
>>>>***Text File***
>>>>mycomputerXP,192.168.0.1,192.168.0.2
>>>>mycomputerNT,192.168.0.1, 192.168.0.2
>>>>
>>>>Dim aText
>>>>Dim iIdx, sInFile,sNextLine
>>>>Dim fso, MyFile,oTextFile
>>>>const ForReading = 1
>>>>Dim strComputer
>>>>Dim strPrimaryDNS
>>>>Dim strSecondaryDNS
>>>>Dim StrDNSServer
>>>>Dim objWMIService
>>>>Dim colItems
>>>>Dim aDNS
>>>>
>>>> 'Set Scripting Object
>>>>sInFile = "C:\temp\dns\DNS.txt"
>>>>set fso = CreateObject("Scripting.FileSystemObject")
>>>>Set oTextFile = fso.OpenTextFile(sInFile, ForReading,
>>>>true)
>>>>
>>>>
>>>>
>>>> 'AtEndOfStream or AtEndOfLine work for files
>>>>opened for reading only
>>>>
>>>>Do Until oTextFile.AtEndOfStream
>>>> sNextLine = Trim(oTextFile.ReadLine)
>>>> If sNextLine <> "" Then
>>>> 'wscript.Echo "Name: " & sNextLine
>>>>
>>>> aText = split(sNextLine,",")
>>>>
>>>> 'wscript.Echo aText(iIdx)
>>>> 'wscript.Echo aText(0)
>>>> 'wscript.Echo aText(1)
>>>> 'wScript.Echo aText(2)
>>>> strComputer = aText(0)
>>>> strPrimaryDNS = aText(1)
>>>> strSecondaryDNS = aText(2)
>>>> aDNS = Array
>>>>(strPrimaryDNS,strSecondaryDNS)
>>>>
>>>> 'Set Networking Managing Objects
>>>> set objWMIService = GetObject("winmgmts:\\" &
>>>>strComputer & "\root\cimv2")
>>>> Set colItems = objWMIService.ExecQuery("Select
>>>>* From Win32_NetworkAdapterConfiguration Where
>>IPEnabled
>>>>= 1")
>>>>
>>>> For Each objItem in colItems
>>>> errDNS =
>>>>objItem.SetDNSServerSearchOrder()
>>>> wscript.sleep 500
>>>> errDNS =
>>>>objItem.SetDNSServerSearchOrder(aDNS)
>>>> Next
>>>>
>>>> End If
>>>>Loop
>>>>
>>>>
>>>>>-----Original Message-----
>>>>>On Tue, 27 Apr 2004 13:04:54 -0700,
>>>>><anonymous@discussions.microsoft.com> wrote:
>>>>>
>>>>>>Here is a snipet of code I am using to change DNS
>>>>entries
>>>>>>on Windows XP and 2003 Server. \
>>>>>>
>>>>>>My questions is: How do I change DNS entries on an
>>NT
>>>>>>4.0 workstation?
>>>>>
>>>>>Have you tried your code on a NT system? What
>>happened?
>>>>>
>>>>>Jeff
>>>>>
>>>>>>'Set Networking Managing Objects
>>>>>>set objWMIService = GetObject("winmgmts:\\" &
>>>>strComputer
>>>>>>& "\root\cimv2")
>>>>>>Set colItems = objWMIService.ExecQuery("Select *
>>From
>>>>>>Win32_NetworkAdapterConfiguration Where IPEnabled =
>>1")
>>>>>>
>>>>>>For Each objItem in colItems
>>>>>>errDNS = objItem.SetDNSServerSearchOrder()
>>>>>>wscript.sleep 500
>>>>>>errDNS = objItem.SetDNSServerSearchOrder(aDNS)
>>>>>>Next
>>>>>
>>>>>.
>>>>>
>>>
>>>.
>>>
>>.
>>
- Next message: Viatcheslav V. Vassiliev: "Re: Server Networking Information"
- Previous message: M: "Server Networking Information"
- In reply to: anonymous_at_discussions.microsoft.com: "Re: Change DNS on NT 4.0"
- Next in thread: anonymous_at_discussions.microsoft.com: "Re: Change DNS on NT 4.0"
- Reply: anonymous_at_discussions.microsoft.com: "Re: Change DNS on NT 4.0"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|