Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-11-01
6
Medium Priority
?
3,804 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
[X]
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
  • 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 600 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
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 …
Simple Linear Regression

718 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