Page 1 of 1 1
Topic Options
#21703 - 2002-05-14 02:08 PM Gateway
Anonymous
Unregistered


Help,

We currently have approx 1000 computers running Win 9x which I need to change the gateway on. There are all running static addressed due to a requirement of a program so we cannot change to DHCP.

I am a little confused how to write a script which will identify the correct key (0001, 0002, etc) under nettrans and update it accordingly.

I have searched the forum but have been unable to find a definitive answer.

Any help

Top
#21704 - 2002-05-14 02:16 PM Re: Gateway
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Try something like this:
code:
$HKLM = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services"
$Index = 0
:Loop1
$KeyName = ENUMKEY( "$HKLM\Class\NetTrans\" , $Index )
$RC = @ERROR
$Index = $Index + 1
$Gateway=ReadValue("$HKLM\Class\NetTrans\$KeyName","DefaultGateway")
If $Gateway = "YourCurrentGateway"
;$ReturnCode = WRITEVALUE( "$HKLM\Class\NetTrans\$KeyName" , "IPAddress" , "0.0.0.0" , "REG_SZ")
;$ReturnCode = WRITEVALUE( "$HKLM\Class\NetTrans\$KeyName" , "IPMask" , "0.0.0.0" , "REG_SZ")
$ReturnCode = WRITEVALUE( "$HKLM\Class\NetTrans\$KeyName" , "DefaultGateway", "0.0.0.0" , "REG_SZ")
EndIf
goto Loop1



[ 14 May 2002, 14:17: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#21705 - 2002-05-14 02:36 PM Re: Gateway
Anonymous
Unregistered


Thanks for that, a great help
One question, when it has updated the gateway how do I get it to break the loop and continue, at present the script runs indefinately.

Thanks again

Top
#21706 - 2002-05-14 03:04 PM Re: Gateway
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Sorry, I removed too much code when I attempted to give you something more toward your goal.
code:
:Loop1
$KeyName = ENUMKEY( "$HKLM\Class\NetTrans\" , $Index )
$RC = @ERROR
$Index = $Index + 1
If $RC = 0
If ...
Do Something ...
Endif
goto Loop1
Endif



[ 14 May 2002, 15:06: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#21707 - 2002-05-14 03:16 PM Re: Gateway
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You might also want to look at the UDF CheckNICs. This UDF checks network card parameters like DNS, WINS, Gateway and corrects them if necessary. The UDF is compatible with Windows 9x, NT, and 2000 and works well if you are using statics IP addresses independend of the network card used. I am using it on about 80 computers with NICs from 4 or 5 different manufacturers and ISA/PCI/PCMCIA/USB cards.
_________________________
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
0 registered and 2175 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.054 seconds in which 0.028 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