Solved

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

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

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

Suggested Solutions

Title # Comments Views Activity
Generate Unique ID in VB.NET 21 136
Is online banking safe? 11 127
MCAT Verbal Reasoning 2 22
Looking for reading material 2 45
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this post we will learn different types of Android Layout and some basics of an Android App.

751 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