Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2006-11-01
6
3,694 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This is about my first experience with programming Arduino.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

829 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