#21703 - 2002-05-14 02:08 PM
Gateway
|
Anonymous
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
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 ]
|
|
Top
|
|
|
|
#21705 - 2002-05-14 02:36 PM
Re: Gateway
|
Anonymous
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
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 ]
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2870 anonymous users online.
|
|
|