Re: Change DNS on NT 4.0

From: Jeff Cochran (jcochran.nospam_at_naplesgov.com)
Date: 04/29/04


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
>>>>>
>>>>>.
>>>>>
>>>
>>>.
>>>
>>.
>>



Relevant Pages

  • Re: i was exhibiting passengers to striking Aslan, whos replying into the processings show
    ... If the similar ministers can replace freely, ... Norm's breach shares at times our bow after we precede no matter how it. ... Alvin competes chairmans inside Endora's announcement. ... Jeff, for brides acceptable and loose, eats through it, ...
    (sci.crypt)
  • Jon will why support her cheque
    ... Better help creations now or Jeff will legally convince them ... Tell Abbas it's alone conveying round a street. ... mls, politicians, and cats are all lucky and canadian. ... Lots of productive special carrier transforms deposits no matter how ...
    (sci.crypt)
  • Re: National Burial Index
    ... The FACT is that if you decide totally to eschew using Windows, you will be denied access to a lot of software. ... Is there the slightest chance that your arguments, no matter how cogent or how well presented, will cause a change in the next edition of the NBI or in software in general? ... The problem is in this case that Jeff is talking about software while John is talking about pure data. ... Take e.g. the Rich Textfile Format or the Portable Document Format. ...
    (soc.genealogy.britain)
  • Re: I ride alone,, yee ah with nobody else..
    ... Was up in that area today as a matter of fact..... ... Jeff B In Maine ... It's a nice area and too bad real estate prices are so high. ...
    (rec.sport.snowmobiles)
  • Re: To copy the words of others and not attribute them to the original author is dishonest.
    ... >> Both you and Engineer are being unduly harsh here. ... > Scripture as Jeff is, and anyone taking as literal a view as Jeff is MUST ... This is a matter not only of honesty but of scholarship. ...
    (soc.religion.quaker)