Re: Change DNS on NT 4.0
From: Jeff Cochran (jcochran.nospam_at_naplesgov.com)
Date: 04/28/04
- Next message: anonymous_at_discussions.microsoft.com: "Re: Reading and Writing to a Text file"
- Previous message: Al Dunbar [MS-MVP]: "Re: How to redirect output of shell command using WMI"
- 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: Wed, 28 Apr 2004 19:14:12 GMT
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: anonymous_at_discussions.microsoft.com: "Re: Reading and Writing to a Text file"
- Previous message: Al Dunbar [MS-MVP]: "Re: How to redirect output of shell command using WMI"
- 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
|