Avatar of cameramonkey
cameramonkeyFlag for United States of America

asked on 

reg query syntax

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?
Windows BatchShell Scripting

Avatar of undefined
Last Comment
cameramonkey
Avatar of DonConsolio
DonConsolio
Flag of Austria image

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

ASKER CERTIFIED SOLUTION
Avatar of DonConsolio
DonConsolio
Flag of Austria image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of cameramonkey
cameramonkey
Flag of United States of America image

ASKER

Awesome! thanks!
Windows Batch
Windows Batch

Batch files are text files containing a script of commands that are executed by the command interpreter on DOS, OS/2 and Windows systems. Most commonly, they are used to perform a series of functions that are repeated -- copying a set of files created daily with one step, for example.

13K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo