Page 1 of 1 1
Topic Options
#126933 - 2004-09-22 05:25 PM Setting DNS & WINS through kix
legalbeagle Offline
Lurker

Registered: 2004-09-21
Posts: 3
I'm new to kix scripting and have just done a whole load of kix scripts that work to the letter but now need to do a script that can set DNS & WINS. Some of the machines on the network already have DNS & WINS specified so i would really need the script to search and see if the two have already been setup. Platforms in use are win9X, 2K and XP.

I've searched the forums and have found a few people asking the same thing but havent found a solid answer to anyone's queries as of yet.

Does anyone have any idea of how to go about doing this? Any help would be well appreciated.

Top
#126934 - 2004-09-22 06:47 PM Re: Setting DNS & WINS through kix
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Here is an ugly one i used a while ago. i didn't write the meat of the script but i'm sure it works. It reads a list of machine names from a file.

See the code below. Thanks Les.


Edited by maciep (2004-09-22 09:08 PM)
_________________________
Eric

Top
#126935 - 2004-09-22 07:17 PM Re: Setting DNS & WINS through kix
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

Sorry about the long lines



That is like people that think that as long as they have their 4-way flashers on, they can park anywhere!

Why not just break the lines? How hard can it be?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#126936 - 2004-09-22 07:45 PM Re: Setting DNS & WINS through kix
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
because i'm lazy. but if it bothers you, feel free to break them up and repost, how hard could it be?
_________________________
Eric

Top
#126937 - 2004-09-22 07:59 PM Re: Setting DNS & WINS through kix
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

how hard could it be?



If I were moderator on the Starters forum, the answer is very easy but since I am not, I cannot edit your post.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#126938 - 2004-09-22 08:02 PM Re: Setting DNS & WINS through kix
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
just make a new reply with the edited code and i will remove the code from my post.
_________________________
Eric

Top
#126939 - 2004-09-22 09:05 PM Re: Setting DNS & WINS through kix
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
OK, but I hate VarsInStrings.

This is not my code, I just shortened the lines.
Code:
BREAK ON

$Wins1 = "1.1.1.1"
$Wins2 = "1.1.1.1"
$Dns1 = "1.1.1.1"
$Dns2 = "1.1.1.1"
$Dns3 = "1.1.1.1"
$list = "C:\winsList.txt"
$log = "C:\winsLog.txt"

$ = open(2, $log, 5)
$ = open(1, $list)
$curComp = trim(readline(1))
while @error = 0 and $curComp <> ""
? $curComp
$_Exit = 0
$_SubnetMask = ""
$Found = 0
$_NicIndex = 0
gosub "DetectOS"
$HKLMSMWNTCV = 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion'
$HKLSSCCSS = 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services'
$HKLMSCCSC = 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control'
if $OS <> "Invalid OS" and $OS <> "Unreachable"
Do
$_NicKey = EnumKey("\\$curComp\$HKLMSMWNTCV\NetworkCards\", $_NicIndex)
If $_NicKey <> ""
$_NicClass = ReadValue("\\$curComp\$HKLMSMWNTCV\NetworkCards\$_NicKey", "ServiceName")
If @Error = 0
$_DHCP = ReadValue("\\$curComp\$HKLSSCCSS\$_NicClass\Parameters\Tcpip", "EnableDHCP")
If $_DHCP = 1
$_SubnetMask = ReadValue("\\$curComp\$HKLSSCCSS\$_NicClass\Parameters\Tcpip", "DhcpSubnetMask")
Else
$_SubnetMask = ReadValue("\\$curComp\$HKLSSCCSS\$_NicClass\Parameters\Tcpip", "SubnetMask")
EndIf
If @Error = 0
If $_SubnetMask <> "0.0.0.0|"
$Found = 1
$_Exit = 1
EndIf
EndIf
If $Found = 1
If $OsType = "WinNT"
$Nul = WriteValue("\\$curComp\$HKLSSCCSS\NetBT\Adapters\$_NicClass", "NameServer", $Wins1, "REG_SZ")
$Nul = WriteValue("\\$curComp\$HKLSSCCSS\NetBT\Adapters\$_NicClass", "NameServerBackup", $Wins2, "REG_SZ")
$Nul = WriteValue("\\$curComp\$HKLSSCCSS\Tcpip\Parameters", "NameServer", $DNS1
+ " " + $Dns2 + " " + $Dns3, "REG_SZ")
EndIf
If ($OsType = "Win2k") Or ($OsType = "WinXP")
$Nul = WriteValue("\\$curComp\$HKLSSCCSS\NetBT\Parameters\Interfaces\Tcpip_$_NicClass", "NameServerList", $Wins1
+ "|" + $Wins2 + "|", "REG_MULTI_SZ")
$Nul = WriteValue("\\$curComp\$HKLSSCCSS\Tcpip\Parameters\Interfaces\$_NicClass", "NameServer", $DNS1
+ "," + $Dns2 + "," + $Dns3, "REG_SZ")
EndIf
$ = writeline(2, $curComp + ",Wins Updated" + @crlf)
EndIf
EndIf
Else
$_Exit = 1
EndIf
If $Found = 0
$_NicIndex = $_NicIndex + 1
EndIf
Until $_Exit = 1
Else
$ = writeline(2, $curComp + "," + $OS + @crlf)
EndIf
$curComp = trim(readline(1))
loop
$ = close(1)
$ = close(2)
RETURN


:DetectOS
;This will determine the exact Operating System of a machine.
$ProductType = ReadValue("\\$curComp\$HKLMSCCSC\ProductOptions","ProductType")
$dos = ReadValue("\\$curComp\$HKLMSMWNTCV", "CurrentVersion")
SELECT
CASE $ProductType = "" and $dos = ""
$OS = "Unreachable"
CASE $dos = "5.1" AND $ProductType = "WinNT"
$OS = "Windows XP"
$OSType = "WinXP"
CASE $ProductType = "WinNT" AND $dos="5.0"
$OS = "Windows 2000 Professional"
$OSType = "WIN2K"
CASE $ProductType = "WinNT"
$OS = "Windows NT Workstation"
$OSType = "WINNT"
CASE 1
$OS = "Invalid OS"
ENDSELECT
Return

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#126940 - 2004-09-25 02:36 AM Re: Setting DNS & WINS through kix
Sealeopard Offline
KiX Master
*****

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

Top
#126941 - 2004-09-27 05:34 PM Re: Setting DNS & WINS through kix
legalbeagle Offline
Lurker

Registered: 2004-09-21
Posts: 3
thats great cheers for that guys!! much apprecaiated...
Top
#126942 - 2004-09-28 01:27 AM Re: Setting DNS & WINS through kix
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
There is also this link

Automating TCP/IP Networking on Clients
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=126141

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 1172 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.141 seconds in which 0.07 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