Jens is totally right in the REG_MULTI_SZ issue.
You should give this a try:
Change WINS om Win2k+
Examples of how to use CngWinsX():
Example 1:
The PC is part of subnet '10.1' and has only one WINS server: 10.1.1.10
code:
CngWinsX('10.1',Split(10.1.1.10))
Example 2:
The PC is part of subnet '10.1.1' and has 2 WINS servers: 10.1.1.10 and 10.1.1.11
code:
CngWinsX('10.1.1',Split(10.1.1.10 10.1.1.11))
The code for CngWinsX(), change WINS on Win2k and WinXP:
code:
Function CngWinsX($SubNet,$WINS)
$oWMI = GetObject("winmgmts:\\.\root\cimv2")
$NICs = $oWMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each $NIC In $NICs
For Each $IPAdr In $NIC.IPAddress
If IsInNet($IPAdr,$SubNet)
$CardID = $NIC.SettingID
$Key = 'HKLM\System\CurrentControlSet\Services\NetBT\Parameters\Interfaces\TcpiP_' + $CardID
$RC = WriteValue($Key,'NameserverList',Join($WINS,'|') + '|','REG_MULTI_SZ')
EndIf
Next
Next
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
-Erik
ps.
There is some mutch more suffisticated UDF's on the forum to check the in net or in subnet issue, also you have to make a check on the PC so the script only runs once, it won't hurt to run it at each logon, but it should not be nessasary.
[ 24. June 2003, 00:02: Message edited by: kholm ]