Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

how to use VBScript to access a registry key that contains '/'

Posted on 2008-11-06
3
Medium Priority
?
533 Views
Last Modified: 2012-08-14
I am trying to get the version number of Rtvscan from the registry.
The key is located in the registry folder  HKLM\Software\Intel\DLLUsage
The key is "C:\Program Files\Symantec AntiVirus\Rtvscan.exe"
I try to set up the registry path as "HKLM\Software\Intel\DLLUsage\VP6\C:\\Program Files\\Symantec AntiVirus\\Rtvscan.exe"
I got an error on the invalid registry key when the script is ran.

How do you quote "\" in the key?
'
' Check registry for Antivirus version number
dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
'
REgPath = "HKLM\Software\Intel\DLLUsage\VP6\C:\\Program Files\\Symantec AntiVirus\\Rtvscan.exe"
'
val = "NULL"
val = objShell.RegRead(RegPath)
' WScript.Echo val
ipos = InStr(1, val, "10.1.6010")
If ipos > 0 Then
   Call objShell.Run("cmd /c Echo .. > C:\Temp\VP6.flg")
End If

Open in new window

VBErr.bmp
0
Comment
Question by:schiu_ca
  • 2
3 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 22914613
The RegRead method is not capable of reading such values.  You will need to use the WMI Registry interface to read such values.  The code below will do the job for you.

Regards,

Rob.
' Check registry for Antivirus version number
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Intel\DLLUsage\VP6"
strValueName = "C:\Program Files\Symantec AntiVirus\Rtvscan.exe"
intReturn = objRegistry.GetStringValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, val)
If IsNull(val) = False Then
	MsgBox val
	ipos = InStr(1, val, "10.1.6010")
	If ipos > 0 Then
	   Call objShell.Run("cmd /c Echo .. > C:\Temp\VP6.flg")
	End If
Else
	MsgBox "Could not find " & strKeyPath & "\" & strValueName
End If

Open in new window

0
 

Author Closing Comment

by:schiu_ca
ID: 31514185
Hi Rob
The script worked great. I just needed to declare objshell at line 12.
        Set objShell = WScript.CreateObject("WScript.Shell")

Thanks
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22917902
Ah, yes, I forgot that bit.  Thanks for the grade.

Regards,

Rob.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question