Andrew
Tue Sep 13 13:24:20 CDT 2005
Then try:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled =
True")
For Each objNetCard in colNetCards
arrGatewayAddress = Array()
arrGatewayMetric = Array(1)
arrDNSServers = Array("192.168.1.100", "192.168.1.200")
objNetCard.SetDNSServerSearchOrder(arrDNSServers)
objNetCard.SetGateways(arrGatewayAddress, arrGatewayMetric)
Next
This will set the DNS to your address and blow away the default gateway. If
you want to put in a different gateway you would put the address in quotes
in the array.
Help on this one came from :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_tasks__networking.asp
--
Andrew C. Madsen
Network Specialist
Harley-Davidson Motor Company
"camaleon_11" <camaleon_11@hotmail.com> wrote in message
news:u917UsHuFHA.3776@TK2MSFTNGP10.phx.gbl...
> yes.
>
> "Andrew Madsen" <andrew.madsen@harley-davidson.com> escribió en el mensaje
> news:O7UgboHuFHA.3452@TK2MSFTNGP14.phx.gbl...
> You want to delete the gateway?
>
> --
> Andrew C. Madsen
> Network Specialist
> Harley-Davidson Motor Company
> "camaleon_11" <camaleon_11@hotmail.com> wrote in message
> news:Oiv7zdHuFHA.1472@TK2MSFTNGP15.phx.gbl...
> > No.
> >
> > "Andrew Madsen" <andrew.madsen@harley-davidson.com> escribió en el
mensaje
> > news:ewIAlbHuFHA.3864@TK2MSFTNGP12.phx.gbl...
> > And now you want to put in a default gateway?
> >
> > --
> > Andrew C. Madsen
> > Network Specialist
> > Harley-Davidson Motor Company
> > "camaleon_11" <camaleon_11@hotmail.com> wrote in message
> > news:OfPWIYHuFHA.4032@TK2MSFTNGP15.phx.gbl...
> > > Yes.
> > > I have a script for example:
> > > IP: 172.16.3.9
> > > Subred: 255.255.255.0
> > > Gateway:
> > > DNS: 172.30.0.1
> > > DNS: 172.30.0.2
> > >
> > > gateway:
> > > "Andrew Madsen" <andrew.madsen@harley-davidson.com> escribió en el
> mensaje
> > > news:OMHcUVHuFHA.3792@TK2MSFTNGP10.phx.gbl...
> > > Do you have a default gateway set already?
> > >
> > > --
> > > Andrew C. Madsen
> > > Network Specialist
> > > Harley-Davidson Motor Company
> > > "camaleon_11" <camaleon_11@hotmail.com> wrote in message
> > > news:ub$MOOHuFHA.600@TK2MSFTNGP10.phx.gbl...
> > > > I want a script in which the DNS is changed by the one that I want.
> That
> > > > this already Ok thanks to you. But I want that in the same script
the
> > > > default gateway was eliminated since I use client proxy. And if you
> > > already
> > > > helped completely me, quisera in the same script to put the IP and
the
> > > > Subred
> > > > Thanks
> > > >
> > > > "Andrew Madsen" <andrew.madsen@harley-davidson.com> escribió en el
> > mensaje
> > > > news:OYX4iGHuFHA.460@TK2MSFTNGP15.phx.gbl...
> > > > Forgive me here but I am having a bit of trouble understanding what
> you
> > > are
> > > > asking. Are you asking to eliminate the default gateway?
> > > >
> > > > --
> > > > Andrew C. Madsen
> > > > Network Specialist
> > > > Harley-Davidson Motor Company
> > > > "camaleon_11" <camaleon_11@hotmail.com> wrote in message
> > > > news:eCzVy5GuFHA.2592@TK2MSFTNGP09.phx.gbl...
> > > > > Thank you, it has been worth me perfectly. Could one make in the
> same
> > > > Script
> > > > > that first it eliminated the gateway (should not it have) and then
> to
> > > > modify
> > > > > the DNS?. THANK YOU
> > > > >
> > > > > "Andrew Madsen" <andrew.madsen@harley-davidson.com> escribió en el
> > > mensaje
> > > > > news:e2wUO0GuFHA.3792@TK2MSFTNGP10.phx.gbl...
> > > > > First off why are you not using DHCP for your workstations?
> > > > >
> > > > > This is from the Scripting guys (
> > > > >
> > > >
> > >
> >
>
http://www.microsoft.com/technet/scriptcenter/resources/qanda/apr05/hey0425.mspx )
> > > > >
> > > > >
> > > > > strComputer = "."
> > > > >
> > > > > Set objWMIService = GetObject("winmgmts:" _
> > > > > & "{impersonationLevel=impersonate}!\\" & strComputer &
> > > "\root\cimv2")
> > > > >
> > > > > Set colNetCards = objWMIService.ExecQuery _
> > > > > ("Select * From Win32_NetworkAdapterConfiguration Where
> IPEnabled
> > =
> > > > > True")
> > > > >
> > > > > For Each objNetCard in colNetCards
> > > > > arrDNSServers = Array("192.168.1.100", "192.168.1.200")
> > > > > objNetCard.SetDNSServerSearchOrder(arrDNSServers)
> > > > > Next
> > > > > --
> > > > > Andrew C. Madsen
> > > > > Network Specialist
> > > > > Harley-Davidson Motor Company
> > > > > "camaleon_11" <camaleon_11@hotmail.com> wrote in message
> > > > > news:usFvhqGuFHA.3068@TK2MSFTNGP14.phx.gbl...
> > > > > > I need a script to change the primary DNS and the Secondary DNS
> for
> > > pcs
> > > > > > Windows Professional XP SP2. Do you help me to build it?. I
don't
> > have
> > > a
> > > > > lot
> > > > > > of idea of VB. Thank you.
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> >
> >
> >
>
>
>