Solved

reg query syntax

Posted on 2010-11-15
3
1,214 Views
Last Modified: 2012-05-10
Ive been pulling my hair out for hours now, and I think its time to call in the reinforcements.

I am trying to determine if a specific version of java is installed during a login script, and if not, excecute a batch file to install it silently.

on another website I found a suggestion for this tack as an example:

reg query HKCU\Software\Winamp
if errorlevel 1 goto not_exist

when I try to put that into real world use, I dont get an errorlevel, but instead get more verbose errors.


for example, I input:
reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{26A24AE4-039D-4CA4-87B4-2F83216022FF}

and instead of getting the expected result code of 0 or 1, I get a list of all of the items under that key if it is installed, or a more verbose "ERROR: The system was unable to find the specified registry key or value." error if it is not.

I dont need to drill down into a software registry key to determine a version value, etc , as just finding the uninstall key is the quickest way for my needs.

ideas? am I missing a switch somewhere to return a result code instead of  verbose messages?
0
Comment
Question by:cameramonkey
  • 2
3 Comments
 
LVL 14

Expert Comment

by:DonConsolio
Comment Utility
simply throw away the messages - you are just interested in the error level

reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{26A24AE4-039D-4CA4-87B4-2F83216022FF}" >nul
if errorlevel 1 goto not_exist

Open in new window

0
 
LVL 14

Accepted Solution

by:
DonConsolio earned 250 total points
Comment Utility
if you want to get rid of messages use ">nul"
if you want to get rid of error messages use "2>nul"

reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{26A24AE4-039D-4CA4-87B4-2F83216022FF}" >nul
if errorlevel 1 goto not_exist

Open in new window

0
 

Author Closing Comment

by:cameramonkey
Comment Utility
Awesome! thanks!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

728 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

14 Experts available now in Live!

Get 1:1 Help Now