Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3850
  • Last Modified:

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

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
dan29
Asked:
dan29
  • 4
1 Solution
 
JRockSolidCommented:
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
 
JRockSolidCommented:
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
 
dan29Author Commented:
That did it!!  I was missing the space after the quotation marks when specifying the registry value.  JRock the gold goes to you!
0
 
JRockSolidCommented:
Thank you.  I have apent hours on the same thing before myself. :)
0
 
JRockSolidCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now