Page 1 of 1 1
Topic Options
#151781 - 2005-11-17 10:04 PM Add a string to reg value.
brewdude6 Offline
Hey THIS is FUN

Registered: 2000-10-21
Posts: 280
Loc: Nashville, TN
Any thoughts on how check if a registry value is set...if so, I need to append to it with a string. Here is what I have so far.

Code:
 
$bbhome=ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\16FD58773EE02F44F9082F014DAF6CC9", "6BB86DA5D449506409F1448FC6560289")
If @error <> 0
? "Error Encountered: " + @serror
MessageBox("Can't find Big Brother install path!", $bbhome, 16)
Exit 0
Else
$bbexternals = ReadValue ("HKEY_LOCAL_MACHINE\SOFTWARE\Quest Software\BigBrother\bbnt\Externals","")
If @error = 0
$bbfolder=$bbhome + "ext"
$bbhomeext=";" + $bbfolder + " /INT=300"
If Not Exist($bbfolder)
MD $bbfolder
$ = updateregistry("HKEY_LOCAL_MACHINE\SOFTWARE\Quest Software\BigBrother\bbnt\Externals","",$bbhomeext,"REG_SZ")
Else
?????
EndIf

_________________________
I could have made a neat retort but didn't, for I was flurried and didn't think of it till I was downstairs.
-Mark Twain

Top
#151782 - 2005-11-17 10:17 PM Re: Add a string to reg value.
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Your missing an endif.
Try this.

Code:

$bbhome=ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\16FD58773EE02F44F9082F014DAF6CC9", "6BB86DA5D449506409F1448FC6560289")
If @error <> 0
? "Error Encountered: " + @serror
MessageBox("Can't find Big Brother install path!", $bbhome, 16)
Exit @ERROR
Else
$bbexternals = ReadValue ("HKEY_LOCAL_MACHINE\SOFTWARE\Quest Software\BigBrother\bbnt\Externals","")
If @error = 0
$bbfolder=$bbhome + "ext"
$bbhomeext=";" + $bbfolder + " /INT=300"
If NOT Exist($bbfolder)
MD $bbfolder
$ = updateregistry("HKEY_LOCAL_MACHINE\SOFTWARE\Quest Software\BigBrother\bbnt\Externals","",$bbhomeext,"REG_SZ")
Else
?"?????"
EndIf
EndIf
EndIf



[edit]
Typo.
[/edit]


Edited by Mart (2005-11-17 10:18 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#151783 - 2005-11-17 10:32 PM Re: Add a string to reg value.
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Read the registry val into a string. If the string is null, just write the info you need back to the registry. If the string isn't null, then concatenate the new data with the string you read, and then write it back.

PseudoCode:

$Val = ReadValue(key, value)
If $Val ; not null
$Val = $Val + "new stuff"
Else
$Val = "new stuff"
EndIf
$ = WriteValue(key, Value, $Val, "type")

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#151784 - 2005-11-17 11:09 PM Re: Add a string to reg value.
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
If you check the KiX manual, you would see that ReadValue:
Quote:

Returns: ASCII representation of the specified registry value.



I can see that you use Val(), but have no idea why. I also have no idea why you cast it to numeric and then try to append a string to it.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#151785 - 2005-11-18 12:04 AM Re: Add a string to reg value.
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Les!

I know you're sufferin' from slow-connection-itis, but it's no reason to hallucinate so... The only reference to "Val()" to cast a numeric is in your own post! (unless $Val and Val() now mean the same thing???)

I suggest that you repent by reciting two Hail Kix's and one Programmer's Creed. Note also that I said "pseudocode:" because I wanted to present an idea that could be taken forth into the flock, er, manual to generate self-inspiration of coding. (OK - That's the last time I fall asleep with the Evangelist Channel on!)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#151786 - 2005-11-18 12:13 AM Re: Add a string to reg value.
brewdude6 Offline
Hey THIS is FUN

Registered: 2000-10-21
Posts: 280
Loc: Nashville, TN
Thanks Glenn.

I need to see if "$bbhomeext" is part of the string in "$bbexternals" and skip the writevalue section if it does.

Code:
 

$bbhome=ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\16FD58773EE02F44F9082F014DAF6CC9", "6BB86DA5D449506409F1448FC6560289")
If @error <> 0
? "Error Encountered: " + @serror
MessageBox("Can't find Big Brother install path!", $bbhome, 16)
Exit 0
Else
$bbexternals = ReadValue ("HKEY_LOCAL_MACHINE\SOFTWARE\Quest Software\BigBrother\bbnt\Externals","")
If @error = 0
$bbfolder=$bbhome + "ext"
$bbhomeext=";" + $bbfolder + "\" + "compaqhw.exe /INT=300"
$bbhomeext1=$bbfolder + "\" + "compaqhw.exe /INT=300"
If Not Exist($bbfolder)
MD $bbfolder
EndIf
If $bbexternals
$bbexternals=$bbexternals + $bbhomeext
Else
$bbexternals=$bbhomeext1
EndIf
$ = WriteValue ("HKEY_LOCAL_MACHINE\SOFTWARE\Quest Software\BigBrother\bbnt\Externals","",$bbexternals,"REG_SZ")



I know I'm missing "endifs", but this is just a snippet.
_________________________
I could have made a neat retort but didn't, for I was flurried and didn't think of it till I was downstairs.
-Mark Twain

Top
#151787 - 2005-11-18 12:20 AM Re: Add a string to reg value.
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
FWIW - when I'm struggling with code, I comment out some of the things that actually DO stuff, and replace those lines with print statements telling me what it THINKS it should do.. Prevents stuff from messing the registry or installing until I know it's going to work.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#151788 - 2005-11-18 12:40 AM Re: Add a string to reg value.
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Doh!
Right you are... me not seeing straight... inferring Val() from $Val.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#151789 - 2005-11-18 06:37 PM Re: Add a string to reg value.
brewdude6 Offline
Hey THIS is FUN

Registered: 2000-10-21
Posts: 280
Loc: Nashville, TN
Will this be true if the value is null?

Code:
 
$bbexternals = ReadValue ("HKEY_LOCAL_MACHINE\SOFTWARE\Quest Software\BigBrother\bbnt\Externals","")
If $bbexternals



I want to find if there is a string, and if there is append it if the new value doesn't exist. I'm just not sure how to check if a value is null.
_________________________
I could have made a neat retort but didn't, for I was flurried and didn't think of it till I was downstairs.
-Mark Twain

Top
#151790 - 2005-11-18 06:57 PM Re: Add a string to reg value.
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The Len($bbexternals) should give you a clue.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 774 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.06 seconds in which 0.026 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