Page 1 of 1 1
Topic Options
#41529 - 2003-06-16 01:30 PM Change DNS
leno Offline
Fresh Scripter

Registered: 2002-09-18
Posts: 30
i need to change the DNS address in win98 through script ( more than 200 pc's ) . dows someone knows how ?
Top
#41530 - 2003-06-16 02:26 PM Re: Change DNS
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Are you not using DHCP???

IIRC the settings are somewhere in the registry...

Search with regedit and use "writevalue" to modify the registry; an example of writevalue can be found int he manual.

If you can't find it or don't know how to change it, report back and I'll take a look when I'm at work...
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#41531 - 2003-06-16 02:40 PM Re: Change DNS
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Tsk.
That sounds like yoou don't use DHCP, do you ?
If not consider to make one of your Servers a DHCP Server.
And in the mean time :

quote:
WriteValue( )

Action: Creates a new key, adds another value-name to an existing key (and assigns it a value), or changes the value of an existing value-name.

Syntax: WriteValue ("subkey", "entry", "expression", "data type")

Parameters: Subkey
Identifies the subkey where you want to write a value entry.

Entry

The name of the entry. To write to the (default) entry of a key, specify an empty string as the entry name ("").

Expression

The data to store as the value of the entry.

REG_MULTI_SZ (multi-string) variables are returned with the pipe symbol ( | ) used as the separator between strings. If a string contains a pipe symbol character, it is represented by two pipe symbol characters ( || ).

Data type

Identifies the data type of the entry. The following data types are supported:
REG_NONE
REG_SZ
REG_EXPAND_SZ
REG_BINARY
REG_DWORD
REG_DWORD_LITTLE_ENDIAN
REG_DWORD_BIG_ENDIAN
REG_LINK
REG_MULTI_SZ
REG_RESOURCE_LIST
REG_FULL_RESOURCE_DESCRIPTOR


Returns: 0 Value successfully written
Error code Function failed


Remarks: If the registry key that you are attempting to write a value to does not exist, it will be automatically created.

See Also: AddKey( ), DelKey( ), DelTree( ), ReadType( ), ReadValue( )

Example: $RC=WriteValue("EZReg\Test", "A MultiString variable", "Line 1|Line 2|Line 3 with a || in it|" "REG_MULTI_SZ")
If @ERROR = 0
? "Value written to the registry"
Endif


If you do have an active DHCP Server :

Edit Scope/Global Option 006 - DNS Server

[ 16. June 2003, 14:42: Message edited by: Jochen ]
_________________________



Top
#41532 - 2003-06-16 06:47 PM Re: Change DNS
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
This is part of my change DNS/DHCP script.

I only post the DNS part for Win98/Me.

Examples of use:

Example 1:
The PC is part of subnet '10.1' and has only one DNS server: 10.1.1.10
code:
ChgDNS98Me('10.1',Split(10.1.1.10))

Example 2:
The PC is part of subnet '10.1.1' and has 2 DNS servers: 10.1.1.10 and 10.1.1.11
code:
ChgDNS98Me('10.1.1',Split(10.1.1.10 10.1.1.11))

code:
Function ChgDNS98Me($SubNet,$DNS)
Dim $Changed,$NICs,$NIC,$i,$Key

$Changed = 0
$NICs = ArrayEnumKey('HKLM\Enum\Network\MSTCP')
For $i = 0 To UBound($NICs)
$NICs[$i] = ReadValue('HKLM\Enum\Network\MSTCP\' + $NICs[$i],'Driver')
Next
For Each $NIC In $NICs
$Key = 'HKLM\System\CurrentControlSet\Services\Class\' + $NIC
If ReadValue($Key,'DriverDesc') = 'TCP/IP'
$IPAdr = ReadValue($Key,'IPAddress')
If IsInNet('$IPAdr',$SubNet)
$Key = 'HKLM\System\CurrentControlSet\Services\VxD\MSTCP'
$Changed = WriteReg($Key,'NameServer',Join($DNS,','),'REG_SZ',$Changed)
EndIf
EndIf
Next
If $Changed
$RC = MessageBox('Your network settings have been changed.' + @CRLF + 'Please reboot the PC','Please reboot the PC',48)
EndIf
EndFunction


Function ArrayEnumKey($Key)
If Not KeyExist($Key)
$ArrayEnumKey = ''
Return
EndIf
$i = 0
$SubKey = EnumKey($Key,$i)
While @Error = 0
ReDim Preserve $ArrayEnumKey[$i]
$ArrayEnumKey[$i] = $SubKey
$i = $i + 1
$SubKey = EnumKey($Key,$i)
Loop
EndFunction


Function IsInNet($IP, $SubNet)
Dim $ChkNet,$ChkIP,$i

If '$IP' = '' Or $IP = '0.0.0.0'
Return
EndIf
$ChkNet = Split($SubNet,'.')
$ChkIP = Split($IP,'.')
For $i = 0 To UBound($ChkNet)
If $ChkNet[$i] <> $ChkIP[$i]
Return
EndIf
Next
$IsInNet = 1
EndFunction


Function WriteReg($Key,$ValueName,$Value,$Type,$Changed)
Dim $Dif

$Dif = 0
If '' + ReadValue($Key,$ValueName) <> $Value
$Dif = 1
EndIf
If '' + ReadType($Key,$ValueName) <> $Type
$Dif = 1
EndIf
If $Dif
$RC = WriteValue($Key,$ValueName,$Value,$Type)
EndIf
$WriteReg = $Changed | $Dif
EndFunction

Because this is a part of my original code you should test it before use.

-Erik

[ 16. June 2003, 18:56: Message edited by: kholm ]

Top
#41533 - 2003-06-16 10:31 PM Re: Change DNS
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Uhhh,

Like I said... It's somewhere in the registry [Big Grin]

Compliments to Erik!!!
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#41534 - 2003-06-17 05:06 PM Re: Change DNS
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See also CheckNICs() - Checks/Updates a NICs TCP/IP settings
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.058 seconds in which 0.027 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org