Page 1 of 1 1
Topic Options
#72166 - 2002-12-09 10:06 AM Script for registry
kalev Offline
Fresh Scripter

Registered: 2002-12-05
Posts: 21
Hello!

Could you tell me why does my script give me the opposite answers? If key exists, it tells me "Key does not exist" and if it does, it tells me "Key exists.."

if ExistKey ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows 2000\SP2\Q282522")
? "Key exists...."
else
? "Key does not exist"
Endif

Also - what command should i use to check the value of a Registry subkey?

Top
#72167 - 2002-12-09 10:15 AM Re: Script for registry
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Thats probably because you use it wrongly :

If you use that with KiXtart 4.x :

KeyExist()

returns 1 if true (similar to Exist())

ExistKey is still supported but in the old way ...

If it is 3.x :

ExistKey()

returns 0 if subkey was found !

So to bring this to the point :

It changed behavior to reflect it more logically ...

The value of a Key ?

Readvalue()

hth

Jochen
_________________________



Top
#72168 - 2002-12-09 10:18 AM Re: Script for registry
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
little correction,
existkey returns always 0 if keyexist no matter what the version.
that is to keep backwards compatibility (<- should learn english...)
_________________________
!

download KiXnet

Top
#72169 - 2002-12-09 10:23 AM Re: Script for registry
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
I said that ... at least me thinx so [Wink]
_________________________



Top
#72170 - 2002-12-09 10:25 AM Re: Script for registry
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yeah.
but you made it sound that "if it's 3.xx, existkey() will return zero if exists"

[Razz]

I know, I know... but who knows, who doesn't know?
_________________________
!

download KiXnet

Top
#72171 - 2002-12-09 10:27 AM Re: Script for registry
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Hello ?

It DOES that acutally:

quote:
EXISTKEY( )

Action: Checks for the existence of a registry subkey.
Syntax: EXISTKEY ("subkey")
Parameters: Subkey
Identifies the subkey you want to locate.

Remarks: The values returned by EXISTKEY have the opposite meaning of the values returned by EXIST.
Returns: 0
Subkey found

1
Subkey not found


Example: $ReturnCode = ExistKey ("HKEY_CURRENT_USER\Console\Configuration")
If $ReturnCode = 0
? "Key exists...."
Endif




[ 09. December 2002, 10:28: Message edited by: jpols ]
_________________________



Top
#72172 - 2002-12-09 10:30 AM Re: Script for registry
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
[Razz]
[Razz]
[Razz] sure, but you didn't say that it's the case for 4.xx too [Razz]
[Razz]
[Razz]
[Razz]


[ 09. December 2002, 10:34: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#72173 - 2002-12-09 10:32 AM Re: Script for registry
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
'I DID!!' , he cries wondering whats wrong with the Lonk [Razz]

quote:
ExistKey is still supported but in the old way ...


[ 09. December 2002, 10:33: Message edited by: jpols ]
_________________________



Top
#72174 - 2002-12-09 10:36 AM Re: Script for registry
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
tired maybe?

I looove this html stuff


[Eek!]

_________________________
!

download KiXnet

Top
#72175 - 2002-12-09 11:09 AM Re: Script for registry
kalev Offline
Fresh Scripter

Registered: 2002-12-05
Posts: 21
So.. Without using "$Returncode" i cant make it be logical? just have to use it the opposite way?
Like that? Or is there a way?

if Existkey ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows 2000\SP2\Q282522")
? "Key does not exist"
else
? "Key exists..."
Endif

Top
#72176 - 2002-12-09 11:17 AM Re: Script for registry
kalev Offline
Fresh Scripter

Registered: 2002-12-05
Posts: 21
[Smile] I got it..
I should not use ExistKey, but KeyExist [Smile]
it works fine now [Smile]

Top
#72177 - 2002-12-09 11:17 AM Re: Script for registry
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
$ReturnCode = function()

is either used to silence a function call(not printing to console),

or to get a value assigned which can be used later on !

It's either :

code:
if Existkey ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows 2000\SP2\Q282522")
? "Key does not exist"
else
? "Key exists..."
Endif

or

code:
if KeyExist("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows 2000\SP2\Q282522")
? "Key exists..."
else
? "Key does not exist"
Endif

J.

[ 09. December 2002, 11:20: Message edited by: jpols ]
_________________________



Top
#72178 - 2002-12-09 11:29 AM Re: Script for registry
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
wonder, should I mess this up a little bit more [Wink]
_________________________
!

download KiXnet

Top
#72179 - 2002-12-09 11:31 AM Re: Script for registry
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
[Mad] [Eek!] [Big Grin] [Roll Eyes]

[ 09. December 2002, 11:31: Message edited by: jpols ]
_________________________



Top
#72180 - 2002-12-09 11:32 AM Re: Script for registry
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
is that yes or no [Razz]
_________________________
!

download KiXnet

Top
#72181 - 2002-12-09 11:40 AM Re: Script for registry
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
indecisive [Big Grin]

Ah, by the way kalev : Glad we could help you [Wink]

[ 09. December 2002, 11:42: Message edited by: jpols ]
_________________________



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 1003 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.07 seconds in which 0.025 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