#152360 - 2005-11-28 07:21 PM
Change MTU?
|
JTestman
Fresh Scripter
Registered: 2005-11-28
Posts: 26
|
Hello.. I need assistance converting this to KiX, I’m not a programmer. I’ve looked over a few post concerning Enumerating Network Connections and I’m confused. 
http://www.kixtart.org/ubbthreads/showfl...true#Post150371
The platform is Windows 2000 Professional SP4 Heres the VB code I wish to convert.
' ----------------------------------------' ' Modify MTU values for remote sites. ' ----------------------------------------'
Option Explicit Dim strComputer, objReg, i, arrAllInterfaces, strKeyPath
Const HKEY_LOCAL_MACHINE = &H80000002 strComputer = "." strKeyPath = "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces" Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\default:StdRegProv") 'Obtain array of all interfaces. objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrAllInterfaces For i = 0 To UBound(arrAllInterfaces) 'Create the "MTU" value entry. objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath _ & "\" & arrAllInterfaces(i), "MTU", 1400
|
|
Top
|
|
|
|
#152363 - 2005-11-29 01:24 AM
Re: Change MTU?
|
JTestman
Fresh Scripter
Registered: 2005-11-28
Posts: 26
|
Thanks for the tip, I’m changing our MTU values so SSL connections can pass through our encryption devices. I’m not the network guy but this works for our offsites.
|
|
Top
|
|
|
|
#152364 - 2005-11-29 01:29 AM
Re: Change MTU?
|
JTestman
Fresh Scripter
Registered: 2005-11-28
Posts: 26
|
I'll look into EnumKeys / EnumValue functions, do you have a example of this function being used?
|
|
Top
|
|
|
|
#152366 - 2005-11-29 01:36 AM
Re: Change MTU?
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
ja its pretty basic, here's a quick example using your situation:
Code:
break on
$index = 0
$key = enumkey("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces", $index)
while $key
?"key=" $key
$index = $index + 1
$key = enumkey("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces", $index)
loop
exit 0
|
|
Top
|
|
|
|
#152368 - 2005-11-29 08:28 AM
Re: Change MTU?
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Another way to use this is to get Dr. Tcp from - http://www.dslreports.com/drtcp ..
Then, do a RegSnap from - Registry Tools
HTH,
Kent
|
|
Top
|
|
|
|
#152370 - 2005-11-30 07:30 PM
Re: Change MTU?
|
JTestman
Fresh Scripter
Registered: 2005-11-28
Posts: 26
|
I found an example that uses the EnumKeys/EnumValue functions, I have looked at he WriteValue function and I need help tying these together. A non working example is below. I need to identify the MTU Value Data to a 1400 decimal value.
How do I tie EnumValue and WriteValue togther? Code:
; EnumKeys.KIX ; ; Enumerates a (registry) key and all its subkeys ; ; Note : This code sample is provided for demonstration purposes only. ; Microsoft makes no warranty, either express or implied, ; as to its usability in any given situation. ; ; Copyright (C) 2001 Ruud van Velsen. ; All rights reserved. ; BREAK ON
IF $Key = 0 $Key = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces" ENDIF
; ; first enumerate all subkeys of current key ; DIM $Index, $SaveKey
$Index = 0 $SubKey = EnumKey( $Key , $Index )
WHILE @ERROR = 0
$SaveKey = $Key
$Key = $Key + "\" + $SubKey
? $Key
CALL EnumKeys
$Key = $SaveKey IF @ERROR = 0
; try for next subkey
$Index = $Index + 1 $SubKey = EnumKey( $Key , $Index ) ENDIF
LOOP
; ; Lastly, enumerate all values of current key ; $Index = 0 $Value = EnumValue( $Key , $Index )
WHILE @ERROR = 0 ? $Key + "|" + $Value $Index = $Index + 1 $Value = EnumValue( $Key , $Index ) LOOP
WriteValue( $Key , $Value "MTU", "1400", "REG_DWORD") If @ERROR = 0 ? "Value written to the registry" Endif
EXIT 0
Edited by JTestman (2005-11-30 08:28 PM)
|
|
Top
|
|
|
|
#152372 - 2005-11-30 11:27 PM
Re: Change MTU?
|
JTestman
Fresh Scripter
Registered: 2005-11-28
Posts: 26
|
Sorry about that!
|
|
Top
|
|
|
|
#152374 - 2005-12-01 01:45 AM
Re: Change MTU?
|
JTestman
Fresh Scripter
Registered: 2005-11-28
Posts: 26
|
Honestly I have no idea the bulk of this script is from a sample scrip included with KIX version 4.51. I added the nonfuncting WriteValue part.
|
|
Top
|
|
|
|
#152379 - 2005-12-01 03:57 AM
Re: Change MTU?
|
JTestman
Fresh Scripter
Registered: 2005-11-28
Posts: 26
|
Thanks for the information! I added the UDF's and attempted to use the WriteValue function. But when I run in debug mode I see that it identifies the MTU value in 2 of 4 keys and I get an error about a missing comma? It scrolls extremely fast so I might have missed something.
Code:
Break On Dim $BaseKey, $Key, $Value $BaseKey = 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces' For each $Key in ArrayEnumKey($BaseKey) If AScan(ArrayEnumValue($BaseKey+'\'+$Key),'MTU')<>-1 'Value ['+ReadValue($BaseKey+'\'+$Key,'MTU')+'] in Key ['+$Key+']' ? EndIf Next
WriteValue( $BaseKey , $Key , $Value "MTU", "1400", "REG_DWORD") If @ERROR = 0 ? "Value written to the registry" Endif
;UDF Function ArrayEnumKey
function arrayenumkey($regsubkey) dim $retcode, $subkeycounter, $currentsubkey, $subkeyarray if not keyexist($regsubkey) $arrayenumkey='' return endif $subkeycounter=0 do $currentsubkey=enumkey($regsubkey,$subkeycounter) if $currentsubkey<>259 and @ERROR=0 redim preserve $subkeyarray[$subkeycounter] $subkeyarray[$subkeycounter]=$currentsubkey $subkeycounter=$subkeycounter+1 endif until $currentsubkey=259 or @ERROR $arrayenumkey=$subkeyarray endfunction
;UDF Function ArrayEnumValue
function arrayenumvalue($regsubkey) dim $retcode, $valuecounter, $currentvalue, $valuearray if not keyexist($regsubkey) $arrayenumvalue='' return endif $valuecounter=0 do $currentvalue=enumvalue($regsubkey,$valuecounter) if $currentvalue<>259 and @ERROR=0 redim preserve $valuearray[$valuecounter] $valuearray[$valuecounter]=$currentvalue $valuecounter=$valuecounter+1 endif until $currentvalue=259 or @ERROR $arrayenumvalue=$valuearray endfunction
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(mole)
and 1300 anonymous users online.
|
|
|