Solved

VbScript - Using Reg Query to find a value associated with a key

Posted on 2006-11-01
6
3,650 Views
Last Modified: 2008-03-03
Hello!

I am using the reg query command line within a vbscript to return a specific value associated with a key.  The problem I am having is that the command ignores the portion where I specify the value to query.  Instead the key with all of it's values are returned (output dumped into a text file).  I have tried using the regread and enumkey methods to return the information I need, but both fail.  Here's the part of the script I am using to do this;

strTextFile = "compliance.txt"
strKeyPath = "HKLM\SOFTWARE\Network Associates\ePolicy Orchestrator\Application Plugins\VIRUSCAN8000"

Set objShell = CreateObject("Wscript.Shell")
objShell.Run "%COMSPEC% /c reg.exe QUERY " _
& Chr(34) & strKeyPath & Chr(34) & "/V DATVersion >>" & strTextFile, 0, True

Any assistance would be much appreciated.  Thank you.

-Dan
0
Comment
Question by:dan29
  • 4
6 Comments
 
LVL 3

Expert Comment

by:JRockSolid
ID: 17853792
Looks like you have it EXCEPT!!!!!!!


strTextFile = "compliance.txt"
                                                                                                                                                           
strKeyPath="HKLM\SOFTWARE\Network Associates\ePolicy Orchestrator\Application Plugins\VIRUSCAN8000"
                                                                                                                                         ^ NEED A SLASH HERE TO PULL VALUES "\VIRUSCAN8000\"    
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "%COMSPEC% /c reg.exe QUERY " _
& Chr(34) & strKeyPath & Chr(34) & "/V DATVersion >>" & strTextFile, 0, True


tRY THAT
0
 
LVL 3

Accepted Solution

by:
JRockSolid earned 150 total points
ID: 17854645
Oh yeah and a space

objShell.Run "%COMSPEC% /c reg.exe QUERY " _
& Chr(34) & strKeyPath & Chr(34) & "/V DATVersion >>" & strTextFile, 0, True
                                                     ^SPACE HERE       " /V DATVersion >>"
0
 

Author Comment

by:dan29
ID: 17875127
That did it!!  I was missing the space after the quotation marks when specifying the registry value.  JRock the gold goes to you!
0
 
LVL 3

Expert Comment

by:JRockSolid
ID: 17878675
Thank you.  I have apent hours on the same thing before myself. :)
0
 
LVL 3

Expert Comment

by:JRockSolid
ID: 17878682
I am in the habbit now of making a variable = to the command and then runing the variable.  This allows you to easily debug by using a msgbox.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
This is an explanation of a simple data model to help parse a JSON feed
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now