Page 1 of 1 1
Topic Options
#153107 - 2005-12-08 03:43 PM ExistKey command problems
Bufe Offline
Lurker

Registered: 2005-12-08
Posts: 3
First of all, hi, I'm new to the forums, and it's nice to meet everybody. I've been using Kix for a while now, very successfully, but I'm trying to use a new script that I'm wrighting to check patch compliance on my network, for some reason, this script is not working properly. I was hoping that some of you could take a look at it, and let me know if you see any reason why it's not working.

$MS05_051 = READVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix\KB902400")
IF $MS05_51 = 0
$MS05_051_S = "Good"
ELSE
$MS05_051_S = "Bad"

;$Message3 = $Message3 + chr(13) + "Patch MS05-51 - Vulnerabilities in MSDTC and COM+ (due date 07 Nov 05)"
ENDIF
$MS05_051 = READVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix\KB902400") + $MS05_051 + " Required Value is: 0"
? '05-287-012 , "$MS05_051_S" , "$MS05_051"'

Basically, when I run this script on my network, everybody is showing up "Good", even when the regestry key does not exist on their machine. Any help with this would be greatly appreaciated.

Top
#153108 - 2005-12-08 03:52 PM Re: ExistKey command problems
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Think you kinda answered your own question, use the KeyExist function ...

Code:

Break On

$MS05_051 = KEYEXIST("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix\KB902400")

IF $MS05_51 = 0
$MS05_051_S = "Good"
ELSE
$MS05_051_S = "Bad"
ENDIF

?"Value=" $MS05_051_S

Exit 0


Top
#153109 - 2005-12-08 04:00 PM Re: ExistKey command problems
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
btw - there is an ExistKey function as well, but its been depracated and has been replaced by KeyExist (which has the proper boolean return codes) - from the manual:

Remarks: KEYEXIST is a replacement to the EXISTKEY function found in previous versions of KiXtart. While functionally equivalent, the Return Codes are now inverted, resulting in behavior similar to the EXIST function.

Top
#153110 - 2005-12-08 04:11 PM Re: ExistKey command problems
Bufe Offline
Lurker

Registered: 2005-12-08
Posts: 3
Awsome, thanks for the fast response. The return codes now seem the be showing up much clearer, however, the problem that I'm getting is this - On a machine that has the patch installed, I get
{05-287-012 , "Good" , "1"}
and on a machine that does not have the patch installed I get
{05-287-012 , "Good" , "0"}

The desired result is, if the return code is "0", it will show up "Bad", but for some reason, it's not doing that.

Top
#153111 - 2005-12-08 04:34 PM Re: ExistKey command problems
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I would suggest you stream-line your code a little bit and go with:

Code:

$MS05_051 = KEYEXIST("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix\KB902400")

IF $MS05_051
$MS05_051_S = "Good"
ELSE
$MS05_051_S = "Bad"
ENDIF

? '05-287-012 , "$MS05_051_S" , "$MS05_051"'



-Shawn

Top
#153112 - 2005-12-08 04:59 PM Re: ExistKey command problems
Bufe Offline
Lurker

Registered: 2005-12-08
Posts: 3
Awesome, that works flawlessly, and with that streamlined look, I might be able to shorten the length of my scripts considerably. Thanks to both of you, you've been a huge help. I was on the verge of pulling out my hair until I came to this forum. Thanks again.
Top
#153113 - 2005-12-08 05:04 PM Re: ExistKey command problems
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Well now, if your really looking for some fancy-schmancy stuff, check-out the Kixtart IFF statement ...

$MS05_051 = KEYEXIST("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix\KB902400")

$MS05_051_S = IIF($MS05_051, "Good", "Bad")

? '05-287-012 , "$MS05_051_S" , "$MS05_051"'

Top
#153114 - 2005-12-08 05:05 PM Re: ExistKey command problems
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
both of the personalities of shawn da basta.
_________________________
!

download KiXnet

Top
#153115 - 2005-12-08 05:06 PM Re: ExistKey command problems
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
lol u basta - I thought you be in here golfing down this some.
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 525 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

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