Page 1 of 1 1
Topic Options
#176491 - 2007-05-25 02:27 PM Check for the existance of a registry value?
Jason W. Offline
Fresh Scripter

Registered: 2003-05-19
Posts: 14
Loc: Orlando, FL
Is there a way to have Kixtart check for a specific registry value? I've seen the KEYEXIST command, but that just checks the registry keys. I need to have it check for a specific value under a key.

I want to use this in an IF statement.

Any help would be appreciated.

Thanks.

Top
#176492 - 2007-05-25 02:49 PM Re: Check for the existance of a registry value? [Re: Jason W.]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Hi Jason,
I think you are looking for the 'ReadValue(SubKey,Entry)' function.

Example:
 Code:
$CPUspeed = ReadValue ("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0","~MHz")
$CPUspeed ?

_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#176500 - 2007-05-25 04:54 PM Re: Check for the existance of a registry value? [Re: Benny69]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Actually, if you want to determine if a value is present, you would use EnumValue. Here's the sample from the manual, modified to exit if the value "XYZZY" is present in the registry key.
 Code:
$Tag = 0
$Index = 0
$ValueName = ENUMVALUE("HKEY_CURRENT_USER\Console\Configuration", $Index)
While Not @ERROR And $Tag = 0
  If $ValueName = "XYZZY"
    $Tag = 1
  EndIf
  $Index = $Index + 1$
  ValueName = ENUMVALUE ("HKEY_CURRENT_USER\Console\Configuration", $Index)
Loop
If $Tag
  "Registry value XYZZY exists!"
EndIf


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

Top
#176503 - 2007-05-25 05:23 PM Re: Check for the existance of a registry value? [Re: Glenn Barnas]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
HUH? What's wrong with using ReadValue()?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#176519 - 2007-05-26 03:37 PM Re: Check for the existance of a registry value? [Re: Les]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The usual confusion with value name and value data \:\)

Edited by Sealeopard (2007-05-27 03:11 AM)
_________________________
There are two types of vessels, submarines and targets.

Top
#176522 - 2007-05-26 11:22 PM Re: Check for the existance of a registry value? [Re: Jason W.]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Well this would work but be careful as this method is NOT exact.

i.e. It will look for 2403 so values like 2405, 2406 etc would not be found and it would say so, but if you did not code otherwise and it only had 240 that would be found and valid as well.

 Code:
Break On
If InStr(ReadValue('HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0','~MHz'),'2403')
  'Value found' ?
Else
  'Value not found' ?
EndIf

Top
#176523 - 2007-05-27 12:17 AM Re: Check for the existance of a registry value? [Re: NTDOC]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
As Jens said, it is the classic confusion about whether it is the *value name* or *value data* that is being sought after.

My read on it is that it is the existence of the value name that the OP is looking for. Using ReadValue() on a non-existing value will throw @Error so @Error can be checked and used like a *ValueExist* function. I fail to see the need to iterate through a loop of all values as Glenn claims as being the right way.
 Code:
Break on
$SO = SetOption('NoMacrosInStrings','on')
$Values = 'foo','CacheAge'
For Each $Value in $Values
  $RC = ReadValue('HKEY_CURRENT_USER\Software\KiXtart\TokenCache',$Value)
  If @Error
    '@Error [' + @Error +']' ?
    "Value " + $Value + " doesn't exist" ?
  Else
    '@Error [' + @Error +']' ?
    "Value " + $Value + " is there!" ?
  EndIf
Next
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#176524 - 2007-05-27 06:00 AM Re: Check for the existance of a registry value? [Re: Les]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Sounds good, at least if he comes back he should now have a few methods to achieve what it is he wants to do.
Top
#176551 - 2007-05-29 02:51 PM Re: Check for the existance of a registry value? [Re: NTDOC]
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I agree with Les.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#176555 - 2007-05-29 03:56 PM Re: Check for the existance of a registry value? [Re: Howard Bullock]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
 Originally Posted By: Howard Bullock
I agree with Les.
PFFT! Be careful...
I seem to be the J.R. Ewing around here, the person that everyone loves to hate... got knocked down to three stars, quickly joining the ranks of Gavin and company. You may want to distance yourself.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#176556 - 2007-05-29 04:06 PM Re: Check for the existance of a registry value? [Re: Les]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
J.R. LOL!... what a hoot!

and by the way, now I got that damn song stuck in my head...
http://simplythebest.net/sounds/Midi/Midi_files/TV_show_Midi_files/dallas.mid

Top
#176557 - 2007-05-29 04:48 PM Re: Check for the existance of a registry value? [Re: Les]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
 Originally Posted By: Les
 Originally Posted By: Howard Bullock
I agree with Les.
PFFT! Be careful...
I seem to be the J.R. Ewing around here, the person that everyone loves to hate... got knocked down to three stars, quickly joining the ranks of Gavin and company. You may want to distance yourself.

Join the club :P

Top
#176562 - 2007-05-29 08:15 PM Re: Check for the existance of a registry value? [Re: Arend_]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Hmmm I know I've not been on the board as much lately but when did the 3 star rating come about? I never did like the algorithm used for it, too easy for a single upset user to ruin a good rating, thus making the rating not a very useful indicator.
Top
#176568 - 2007-05-29 10:30 PM Re: Check for the existance of a registry value? [Re: Arend_]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
 Originally Posted By: apronk

Join the club :P

Ja, well at least I'll admit I had a hand in your three star rating for dis'n Bob and Steve.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#176569 - 2007-05-29 10:35 PM Re: Check for the existance of a registry value? [Re: Allen]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
 Originally Posted By: Allen
J.R. LOL!... what a hoot!

and by the way, now I got that damn song stuck in my head...
Ja, well... I got Tears For Fears "Shout" stuck in my head and I'm partly to blame for that one. :@
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#176574 - 2007-05-30 08:31 AM Re: Check for the existance of a registry value? [Re: Les]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Les: You could pm me, so we could have a private conversation about this. Or add me to MSN if you like.
Top
#176589 - 2007-05-30 02:48 PM Re: Check for the existance of a registry value? [Re: Arend_]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
'nuf said.
_________________________
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:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.162 seconds in which 0.084 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org