#41941 - 2003-06-23 03:50 PM
Changing WINS with a script
|
anthonyalderson
Getting the hang of it
Registered: 2003-03-20
Posts: 52
Loc: England
|
okay guys so i altered my subject title a little but yes i'm still stuck on this topic.
I've tried grasshoppers script which can be located in scripts\changing wins remotely. but so far i've been unsuccessful, i'm totally lost on this one, i see the script checking the number of network cards and building an array based on this and then it checks the cards in the array and rewrites the values but for some reason guys its not, and i do have the dependency tied in with it, but i'm sure theres more than one key that needs changing, namely controlset001, controlset002 and currentcontrolset.
Now i'm starting to blabber a bit here so could anyone put me straight on this.
Anth "seems like i'm here everyday now"
|
|
Top
|
|
|
|
#41943 - 2003-06-23 04:02 PM
Re: Changing WINS with a script
|
anthonyalderson
Getting the hang of it
Registered: 2003-03-20
Posts: 52
Loc: England
|
well i tried but i'm new around here arent i jens, oh and thanks for being so blunt, sounds like you're having as bad a day as i am, so why dont you get off your high horse and help me instead of quoting the rules like some kind of supreme moderator.
Original Thread = http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=2;t=004433
oh and i know that the changes wont take effect until a reboot, all i'm asking for jens is a little help in understanding how the script works rather than simply copying and pasting it and hoping that it works.
oh and by the way i do like your straight to the point attitude, but sometimes you need to relax.
Anth "says it like it is"
|
|
Top
|
|
|
|
#41946 - 2003-06-23 04:21 PM
Re: Changing WINS with a script
|
anthonyalderson
Getting the hang of it
Registered: 2003-03-20
Posts: 52
Loc: England
|
Thanks jens,
first off then i've substituted nameserver and nameserverbackup values for the ip addresses of my primary and secondary wins servers.
i then run the script, restart the machine and hey presto everythings still the same, why is that, oh and the currentcontrolset\services\netbt\adapters key doesnt exist, so what exactly is the code doing then. maybe its my network i mean the script is set up for winnt and xp but nothing with regards to win2k, i know win2k is an evolution of winnt but the keys are slightly different in that win2k has the currentcontrolset\services\netbt\parameters\interfaces rather than the aforementioned.
Where am i going wrong????
Oh and thanks again for being such a sport jens, much appreciated.
Anth
|
|
Top
|
|
|
|
#41947 - 2003-06-23 04:26 PM
Re: Changing WINS with a script
|
anthonyalderson
Getting the hang of it
Registered: 2003-03-20
Posts: 52
Loc: England
|
see i tried that originally lligetfa (nice name by the way!)
and we stumbled upon the chance of being able to introduce a generic regfix across our network but with each machine being different from the previous it just wouldnt work.
so now i'm stuck on trying to rewrite the keys with a script, doing the same task manually within the GUI results in all three keys being changed (namely controlset001, controlset002 and currentcontrolset)
i'm just wondering mainly why grasshoppers script doesnt seem to contain the keys i'm working with.
Anth
|
|
Top
|
|
|
|
#41949 - 2003-06-23 04:41 PM
Re: Changing WINS with a script
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Couple of comments..
MyCompany is not a real company - HKLM\SOFTWARE\MyCompany\DesktopSettings. In other words, this is using stored values.
code:
$TCPIPUpdate=ReadValue("HKLM\SOFTWARE\MyCompany\DesktopSettings","TCPIP_"+$NicCrd)
$nic='{DF842C73-F54F-4BB1-9C0F-6DF384DD2999}' HKLM\System\CurrentControlSet\Services\NetBT\Parameters\Interfaces\Tcpip_'+$nic 'NetbiosOptions' 'REG_DWORD' HKLM\System\CurrentControlSet\Services\NetBT\Parameters\Interfaces\Tcpip_'+$nic 'DhcpNameServerList' 'REG_MULTI_SZ' HKLM\System\CurrentControlSet\Services\NetBT\Parameters\Interfaces\Tcpip_'+$nic 'NameServerList' 'REG_MULTI_SZ'
HTH,
Kent
|
|
Top
|
|
|
|
#41950 - 2003-06-23 04:50 PM
Re: Changing WINS with a script
|
anthonyalderson
Getting the hang of it
Registered: 2003-03-20
Posts: 52
Loc: England
|
and i cant stress enough how much help you guys give me, i know i'm a pain in the arse and to tell you the truth i havent looked at jens checknics script yet... i've been stuck trying to work out grasshoppers script and i feel quite confident in using the registry, i'm only changing a few keys i know and only changing values that i definitely know can be changed, regardless of the registry itself the machine can be rebuilt if i screw up, this is why we keep images in case of people like me lol,
secondly i think mr kdyer has just answered what i needed to know, the keys i was changing were windowsnt keys and now i know the full code for the respective windows 2000 keys i think i should be able to change them,
and should i get stuck i think i'll reenter the bb as someone else just to hide from you lot lol,
Thanks again everyone, you're too much help and i know what a pain it is trying to reverse engineer someone elses code.
Much appreciated guys, and jens i'm gonna go and take a look at your code to see if it can help,
Anth
|
|
Top
|
|
|
|
#41951 - 2003-06-23 05:08 PM
Re: Changing WINS with a script
|
Grasshopper75
Getting the hang of it
Registered: 2002-01-15
Posts: 99
Loc: Melbourne, Australia
|
What have I started ??
The script I put together was to remove static WINS and DNS entries within my environment. I posted it as an example and nothing more. But in either case, it should work if you want to rewrite the reg keys for NT & XP. I did not include W2K as we do not use it in my environment.
I too still class myself as a newbie even though I have been playing with Kix for a while now, I'm learning new things everyday with the majority of help coming from people on this board. While it can be frustrating have to work out someone elses code you need to do it in order to fully understand what it is doing.
I hope you have managed to sort it out in the end.
Grasshopper75
|
|
Top
|
|
|
|
#41952 - 2003-06-23 05:13 PM
Re: Changing WINS with a script
|
Grasshopper75
Getting the hang of it
Registered: 2002-01-15
Posts: 99
Loc: Melbourne, Australia
|
BTW, I'm not sure how much of my script you used but my script writes a reg key the first time you run it to prevent it running again so maybe it hasn't changed anything because the reg key exists.
|
|
Top
|
|
|
|
#41953 - 2003-06-23 05:37 PM
Re: Changing WINS with a script
|
anthonyalderson
Getting the hang of it
Registered: 2003-03-20
Posts: 52
Loc: England
|
thanks grasshopper, i noticed your script runs once because of the new tcpip update data, i've left this in myself so i can ensure mine runs only once itself,
i've managed to adapt your code though so it runs on win2k now, simply changing the product type and relevant keys but for some reason it still isnt doing what it should, maybe if i get it to change the entire controlset rather than just the currentcontrolset it may work, i feel like i'm an inch away from getting it working but its still an inch too far......
thanks for getting me started on this one everybody, i can see it giving me a headache for the next week or so......
Anth
|
|
Top
|
|
|
|
#41954 - 2003-06-23 05:39 PM
Re: Changing WINS with a script
|
Grasshopper75
Getting the hang of it
Registered: 2002-01-15
Posts: 99
Loc: Melbourne, Australia
|
Post your code up so we can have a look at it, sometimes staring at the same code all day makes you miss the simplest of things. Remember to put your code within the code tags though.
|
|
Top
|
|
|
|
#41955 - 2003-06-23 05:48 PM
Re: Changing WINS with a script
|
anthonyalderson
Getting the hang of it
Registered: 2003-03-20
Posts: 52
Loc: England
|
okay i'm in a bit of a rush myself, finishing work now so i'll leave it up but its a bit of a mess at the moment, its basically your code grasshopper but i havent finished adapting it for win2k,
here it is anyway
code:
; Kix script to 'fix' registry keys with regards to NIC's ; Authored from Kix Bulletin Board, courtesy of grasshopper and sealeopard
CALL "arrayenumkey.kix"
$NicKey = EnumKey ("HKLM\Software\Microsoft\Windows NT\CurrentVersion\NetworkCards",0) $NicCrd = ReadValue ("HKLM\Software\Microsoft\WindowsNT\CurrentVersion\NetworkCards\"+$NicKey,"ServiceName") $TCPIPUpdate=ReadValue("HKLM\SOFTWARE\MyCompany\DesktopSettings","TCPIPUpdate") If $TCPIPUpdate<>"Updated" If @PRODUCTTYPE="Windows 2000 Professional" $array=arrayenumkey('HKLM\System\CurrentControlSet\Services\NetBT\Parameters\Interfaces\') For Each $NicCrd In $array WriteValue ("HKLM\System\CurrentControlSet\Services\NetBT\Parameters\Interfaces\Tcpip_"+$NicCrd,"NameServerList","192.168.12.55","REG_SZ") Next WriteValue ("HKLM\System\CurrentControlSet\Services\Tcpip\Parameters", "Domain","", "REG_SZ") WriteValue ("HKLM\System\CurrentControlSet\Services\Tcpip\Parameters", "NameServer","", "REG_SZ") WriteValue ("HKLM\System\CurrentControlSet\Services\Tcpip\Parameters", "SearchList","","REG_SZ") EndIf WriteValue ("HKLM\SOFTWARE\MyCompany\DesktopSettings","TCPIPUpdate","","REG_SZ") EndIf
sorry if its a mess everyone, just i am in a rush and i should have it fully finished tonight at home anyway so i may be back online later.
Anth
|
|
Top
|
|
|
|
#41957 - 2003-06-23 06:41 PM
Re: Changing WINS with a script
|
anthonyalderson
Getting the hang of it
Registered: 2003-03-20
Posts: 52
Loc: England
|
yes i think you could be right there jens, i'll have to try it tomorrow when i'm back at work and let you know the results, it must have slipped through the net that one,
thanks again jens,
Anth
|
|
Top
|
|
|
|
#41958 - 2003-06-24 12:00 AM
Re: Changing WINS with a script
|
kholm
Korg Regular
   
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
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 ]
|
|
Top
|
|
|
|
#41959 - 2003-06-24 10:34 AM
Re: Changing WINS with a script
|
anthonyalderson
Getting the hang of it
Registered: 2003-03-20
Posts: 52
Loc: England
|
thanks erik, at the moment we only want to change the wins across our network so i think this script will do for now and yes jens was right about the reg_multi_sz, it also helped point me in a new direction of checking every key in there to ensure it was right,
you know i spent half the night looking at that code and now i thank god that i did, its helped me to understand a few more bits of kix, like arrays and some commands, think i'm getting better at this all the time lol,
anyway i've almost finished the code which looking at it could have been done a lot quicker had i known previously what i was doing, anyway here it is guys,
code:
; Kix script to 'fix' registry keys with regards to NIC's ; Authored from Kix Bulletin Board, courtesy of grasshopper, sealeopard and all those who helped
CALL "arrayenumkey.kix"
$NicKey = EnumKey("HKLM\Software\Microsoft\Windows NT\CurrentVersion\NetworkCards\",0) $NicCrd = ReadValue("HKLM\Software\Microsoft\WindowsNT\CurrentVersion\NetworkCards\"+$NicKey,"ServiceName") $TCPIPUpdate=ReadValue("HKLM\SOFTWARE\MyCompany\DesktopSettings","TCPIPUpdate") If $TCPIPUpdate<>"Updated" If @PRODUCTTYPE="Windows 2000 Professional" $array=arrayenumkey('HKLM\System\CurrentControlSet\Services\NetBT\Parameters\Interfaces\') For Each $NicCrd In $array WriteValue("HKLM\System\CurrentControlSet\Services\NetBT\Parameters\Interfaces\"+$NicCrd,"NameServerList","192.168.10.100","REG_MULTI_SZ") Next WriteValue("HKLM\System\CurrentControlSet\Services\Tcpip\Parameters", "Domain","", "REG_SZ") WriteValue("HKLM\System\CurrentControlSet\Services\Tcpip\Parameters", "NameServer","", "REG_SZ") WriteValue("HKLM\System\CurrentControlSet\Services\Tcpip\Parameters", "SearchList","","REG_SZ") EndIf WriteValue("HKLM\SOFTWARE\MyCompany\DesktopSettings","TCPIPUpdate","","REG_SZ") EndIf
Just got one or two little problems to iron out at present, namely i need to enter two wins addresses rather than the one thats in, and i also need to ensure the code picks up the correct nic rather than all of them on each workstation.
Any ideas guys.......
Anth "From the land that time forgot"
|
|
Top
|
|
|
|
#41960 - 2003-06-24 10:40 AM
Re: Changing WINS with a script
|
Grasshopper75
Getting the hang of it
Registered: 2002-01-15
Posts: 99
Loc: Melbourne, Australia
|
Jens,
I noticed in your CheckNic() UDF that you did not include XP because of problems writing to the registry ? I now need to add a DNS suffix which I am having no luck doing under XP. What problems did you have when you were writing you UDF ?
Grasshopper75
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 987 anonymous users online.
|
|
|