Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot list strValue.

Status
Not open for further replies.

Grunty

Technical User
Jul 30, 2002
100
GB
Hello,

I am trying to list the Virus Definition Version listed in the registry using the following code:

Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Network Associates\TVD\ViruScan Enterprise\CurrentVersion"
strValueName = "szVirDefVer"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
Wscript.Echo "The Virus Definition is: " & strValue


Trouble is, when I run it, all I get is a message saying "The Virus Definition is: " and no value.

can anyone help me with a solution?

Thanks
 
'try a
Set WshShell = CreateObject("Wscript.Shell")
On Error Resume Next
strValue = WshShell.RegRead("HKLM\SOFTWARE\Network Associates\TVD\ViruScan Enterprise\CurrentVersion")
On Error Goto 0
If strValue = "" Then
Wscript.Echo "no reg value found"
Else
Wscript.Echo strValue
End If

why use WshShell over WMI??? i would say it is faster and easier to read/understand and typically you would be using WshShell in most scripts anyway. WMI is good for reading reg values not support by WshShell or when you want to EnumKeys or Values
 
>strKeyPath = "SOFTWARE\Network Associates\TVD\ViruScan Enterprise\CurrentVersion"
Try this.
[tt]strKeyPath = "SOFTWARE\Network Associates\TVD\Viru[red]s[/red]Scan Enterprise\CurrentVersion" [/tt]
Over time with various releases, it seems the key changes slightly. In any case, physically check the key and the script won't lie about it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top