#153107 - 2005-12-08 03:43 PM
ExistKey command problems
|
Bufe
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
   
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
|
|
|
|
#153110 - 2005-12-08 04:11 PM
Re: ExistKey command problems
|
Bufe
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
   
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
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
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 525 anonymous users online.
|
|
|