Easy way to check if registry key is specific value

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
megasound

Easy way to check if registry key is specific value

Post by megasound »

hi there,
i am new and first of all i want to say that this is a great program for monitoring. I use to have Alchemy Eye pro dus they DO NOT have any active/passive way to monitor the remote systems.

i have a small question.
Is there a quick way (test method) to see if there is a special registry key that has a specific value ?

example :
i want to see if the WINDOWS XP firewall is ACTIVE...not the service but the config.
The correct way is to see if the registry key (EnableFirewall) has the value of : 00000001
see the complete string below

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile]
"EnableFirewall"=dword:00000001

so...how do i test this ?????
many thanks in advance :D
Menno
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

I would recommend you to use "Active Script" test method: http://www.ks-soft.net/hostmon.eng/mfra ... htm#script
Example of the script that reads from registry is included into HostMonitor package. You may find regread.js and regread.vbs in \Examples\Scripts subfolder of HostMonitor folder.

Regards,
Max
Last edited by KS-Soft Europe on Tue Nov 18, 2008 6:41 am, edited 1 time in total.
megasound

yes i saw that

Post by megasound »

...but i am not a VBS scpecialist...
i have tried that and scripts fails everytime....

i can NOT set the dword value somewere...
i only want to see if the registry value (on some remote machies) are dword:000001

maybe some can help me with it ?
thanks in advance
menno

the script


Option Explicit

const statusAlive = "Host is alive:"
const statusDead = "No answer:"
const statusUnknown = "Unknown:"
const statusNotResolved = "Unknown host:"
const statusOk = "Ok:"
const statusBad = "Bad:"
const statusBadContents = "Bad contents:"

const FWon = "HKLM\System\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\EnableFirewall"

'---- entry point ----

FUNCTION performtest()
Dim WshShell, KeyStr
IF "%Reply%"="%"+"Reply"+"%" THEN
performtest = statusUnknown+"Please enable 'Translate macros' option"
ELSE
Set WshShell = CreateObject("WScript.Shell")
KeyStr = WshShell.RegRead(FWon)
IF (KeyStr<>"%Reply%") THEN
performtest = statusBad+KeyStr
ELSE
performtest = statusOk+KeyStr
END IF
END IF
END FUNCTION
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Option Explicit
const statusAlive = "Host is alive:"
const statusDead = "No answer:"
const statusUnknown = "Unknown:"
const statusNotResolved = "Unknown host:"
const statusOk = "Ok:"
const statusBad = "Bad:"
const statusBadContents = "Bad contents:"

const FWon = "HKLM\System\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\EnableFirewall"

'---- entry point ----

FUNCTION performtest()
Dim WshShell, KeyStr
Set WshShell = CreateObject("WScript.Shell")
KeyStr = WshShell.RegRead(FWon)
IF (KeyStr<>1) THEN
performtest = statusBad+CStr(KeyStr)
ELSE
performtest = statusOk+CStr(KeyStr)
END IF
END FUNCTION
Post Reply