Page 1 of 1 1
Topic Options
#206354 - 2012-12-03 02:02 PM finding the right terms for "keyExist"
schade Offline
Just in Town

Registered: 2009-07-29
Posts: 1
Loc: germany, bavaria
Hi i am looking for a way to check if a string exists in the registry.
i tried this.. but it wont work
$ReturnCode = KeyExist("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout\Scancode Map")
If $ReturnCode
? "Keyboarderror will be fixed"
Shell "%logonserver%\keyboardfix\keyboardfix.bat"
EndIf

any ideas?

Top
#206355 - 2012-12-03 02:53 PM Re: finding the right terms for "keyExist" [Re: schade]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
Welcome to KORG!

Just a quick look at a few systems here - none have the "Scancode Map" sub-key. If the key isn't present, the command won't be executed.

You might want to add something like
 Code:
'Returned: ' $ReturnCode ?
to see what is being returned. I'd also confirm that the key exists when you're testing.

Glenn

PS - using code tags will make your script more readable - start with the word "code" in square brackets, and end with "/code" in square brackets.
_________________________
Actually I am a Rocket Scientist! \:D

Top
#206356 - 2012-12-03 02:58 PM Re: finding the right terms for "keyExist" [Re: Glenn Barnas]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Me thinks you are confusing values for keys and that what you really want to find is a value.

In regedit, keys are in the left pane, values in the right pane.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#206357 - 2012-12-03 03:31 PM Re: finding the right terms for "keyExist" [Re: Les]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
Good catch, Les..

This link does indeed identify the item in question as a Value, not a key.. As such, the original code will never return true.

You might want to use ReadValue(key, value) to determine if the setting is defined, or is defined to an unwanted value and then change it.

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

Top
#206358 - 2012-12-03 04:32 PM Re: finding the right terms for "keyExist" [Re: Glenn Barnas]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
This should put you back on track.

 Code:
$nul = ReadValue("HKLM\System\CurrentControlSet\Control\Keyboard Layout","Scancode Map")

If @Error = 0
   ? "Keyboarderror will be fixed"
   Shell "%logonserver%\keyboardfix\keyboardfix.bat"
EndIf

I would also recommend posting the contents of your keyboardfix.bat file as I'm certain it could all be done in kix rather than calling a separate file.

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 1046 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.096 seconds in which 0.068 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