Re: Change DNS on NT 4.0

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


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



Relevant Pages

  • RE: export user accounts from NT 4.0 domain
    ... ATTENTION THE SCRIPT MUST BE RUNNED FROM A COMPUTER WHERE EXCEL IS ... from the information in a Microsoft Excel spreadsheet. ... Dim strLast, strFirst, strMiddle, strPW, intRow, intCol ... On Error GoTo 0 ...
    (microsoft.public.windows.server.scripting)
  • Re: Password Expire
    ... We have one fron end Edge server in our DMZ which passes email onto two ... I used to schedule a script to run every 24 hours on my Exchange 2003 ... Dim fso, txtarray, BodyText ... Call ProcessFolder (objContainer, numDays) ...
    (microsoft.public.exchange.admin)
  • Re: LDAP query information
    ... a "Dim" statement. ... execution of the script. ... ' Filter on computer object. ... ' Construct LDAP syntax query. ...
    (microsoft.public.windows.server.scripting)
  • Re: ADSI Problem
    ... Right I've got the script working now with my ASP applications by passing the ... If you are doing forms authentication using ADSI (which it sounds like you ... Restarting IIS usually gets it working again. ... Dim strUserName ...
    (microsoft.public.windows.server.active_directory)
  • Re: Script: Remote shutdown of all domain computers
    ... When trying to run the script from a XP workstation, where i am logged in as ... Dim strBase, strFilter, strAttributes, strQuery, objRecordSet ... 2000 or above and allow shutdown, ... Public Function AllComputersAs String() ...
    (microsoft.public.windows.server.scripting)

Loading