Page 1 of 1 1
Topic Options
#133021 - 2005-01-26 10:49 PM Writing to the Reg
JoshW Offline
Fresh Scripter

Registered: 2000-04-04
Posts: 31
Loc: Moline, Il 61265
Does anyone see an issue with this line?

WriteValue($HKLMVal + $Keyname + "\" + $ValueName, "MTU", "1300", "reg_dword")

Its part of this larger body. Everything works down to that WriteValue. If finds the right entry and just doesnt do the write.

$Index = 0
:Loop1
$HKLMVal = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\"
$KeyName = ENUMKEY($HKLMVal, $Index)
If @ERROR = 0
;;;;;;;;;;
$Index2 = 0
:Loop2
$ValueName = ENUMVALUE($HKLMVal + $Keyname, $Index2)
If @ERROR = 0
If $ValueName = "DhcpIPAddress"
$VPNIP = ReadValue($HKLMVal + $Keyname,$ValueName)
$ipsegment1 = Val(ltrim(SubStr($VPNIP, 1, 3)))
$ipsegment2 = Val(ltrim(SubStr($VPNIP, 5, 3)))
If $ipsegment1 = 192
If $ipsegment2 = 168
WriteValue($HKLMVal + $Keyname + "\" + $ValueName, "MTU", "1300", "reg_dword")
? "Path = " + $HKLMVal + $Keyname + "\" + $ValueName
If @ERROR <> 0
? "Value Not written to the registry"
Endif
EndIf
EndIf
EndIf
$Index2 = $Index2 + 1
goto Loop2
Endif
;;;;;;;;;;
$Index = $Index + 1
goto Loop1
Endif
_________________________
Josh

Top
#133022 - 2005-01-26 11:07 PM Re: Writing to the Reg
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
The syntax looks OK. Have you tried evaluating @ERROR after the WriteValue attempt?
Top
#133023 - 2005-01-26 11:39 PM Re: Writing to the Reg
JoshW Offline
Fresh Scripter

Registered: 2000-04-04
Posts: 31
Loc: Moline, Il 61265
I found it. By including + "\" + $ValueName, i had gone too far and it was trying to write a reg value to a reg value. I took that off and actually wrote the value to the key instead.
_________________________
Josh

Top
#133024 - 2005-01-30 02:53 PM Re: Writing to the Reg
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You'll also need admin rights to write to that location.
_________________________
There are two types of vessels, submarines and targets.

Top
#133025 - 2005-02-17 01:51 AM Re: Writing to the Reg
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
I would not use GOTO and I'd look at using one or both of these UDFs if needed.

ARRAYENUMKEY() - Creates an array of names of the subkeys contained in a registry key
ArrayEnumValue() - Creates an array of names of the registry entries

Then use a FOR NEXT loop.


By the way JOSH... you post too much. You've been registered on this board longer them me, but you only have 31 posts.


Edited by NTDOC (2005-02-17 02:41 AM)

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 507 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.053 seconds in which 0.023 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