Login | |
|
 |
A simple question, but hard to phrase on google! - 6/22/2007 5:26:37 AM
|
|
 |
|
| |
bread555
Posts: 1
Score: 0
Joined: 6/22/2007
Status: offline
|
Im writing a script to check the virus def version of McAfee against another server. However, because of the realities of life, I dont expect them to be exact every time. Is it possible to a If <> then, statement have a buffer, so it could be with in a range something like If <>+5 then.... That way it has to be within 5 numbers to trigger the then statement. I have attached the script below. Thanks ahead of time!!! Const HKEY_LOCAL_MACHINE = &H80000002 Set StdOut = WScript.StdOut 'Below are the config settings for the script. Enter the PC names that are to be checked strComputer = ("computer1") strComputer2= ("computer2") 'This checks the remote registry Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ strComputer & "\root\default:StdRegProv") ' This is the actual Registry path that you wish to goto strKeyPath = "SOFTWARE\Network Associates\TVD\Shared Components\VirusScan Engine\4.0.xx" 'This is the Value that you are trying to return strValueName = "szVirDefVer" ' This actually shows the whole path, HKLM, where you are going to (strKeyPath), and the value (strValue) oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue 'This pops up a message saying hi! 'MsgBox "Current Virus Def is: " & strValue Set oReg2=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ strComputer2 & "\root\default:StdRegProv") strKeyPath2 = "SOFTWARE\Network Associates\TVD\Shared Components\VirusScan Engine\4.0.xx" strValueName2 = "szVirDefVer" oReg2.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath2,strValueName2,strValue2 'MsgBox "Current Virus Def is: " & strValue2 ' The below statement compares the two values and see's if they are identical. If they are not, It activates ' the subroutine of "Email" if it is correct, it does nothing If strValue <> strValue2 Then Email End If
|
|
| |
|
|
|
 |
RE: A simple question, but hard to phrase on google! - 6/22/2007 5:55:03 AM
|
|
 |
|
| |
ebgreen
Posts: 5034
Score: 31
Joined: 7/12/2005
Status: online
|
Something like this: nRange = 5 nVal1 = 'Whatever is on server 1 nVal2 = 'Whatever is on server 2 If (nVal2 >= (nVal1-nRange)) And (nVal2 <= (nVal1 + nRange)) Then 'It is ok Else 'It is not End if
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: A simple question, but hard to phrase on google! - 6/22/2007 3:28:21 PM
|
|
 |
|
| |
dm_4ever
Posts: 2663
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
|
To be on the safe side you may want to ensure the value you retrieve from the registry is treated as a number by using the CInt function i.e. strValue = CInt(strValue) strValue2 = CInt(strValue2) and then try what ebgreen suggested.
_____________________________
dm_4ever My philosophy: K.I.S.S - Keep It Simple Stupid Read Me: http://www.visualbasicscript.com/m_24727/tm.htm Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
|
|