Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
DOS/Other
Tag Cloud
access acer asus bios bsod computer crash desktop dns driver drivers error ethernet excel freeze gaming graphics hard drive hardware hdmi internet laptop malware memory monitor motherboard network printer problem ram registry repair router slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > DOS/Other >
Solved: Trying to clean up a batch file... need help

Reply  
Thread Tools
raven6988's Avatar
Junior Member with 28 posts.
 
Join Date: Feb 2010
Experience: Intermediate
04-Feb-2010, 06:54 AM #1
Solved: Trying to clean up a batch file... need help
Hello,

I am currently working on doing a registry search for mulitple versions of a software using command line. I have the .bat file working but I am trying to find a way to clean it up so that, instead of showing error when a certain version is not found. It will only show the version that is showing up in the registry. Again this is all done thru remote connections and running scripts and I am trying to make it a bit more readable then dealing with 6 errors and then the information I want. Any help would be greatly appreciated. Below is the current .bat that I have working.

----
REG Query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AC7 6BA8-7AD7-1033-7B44-A93000000001} /v DisplayName

REG Query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AC7 6BA8-7AD7-1033-7B44-A92000000001} /v DisplayName

REG Query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AC7 6BA8-7AD7-1033-7B44-A91000000001} /v DisplayName

REG Query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AC7 6BA8-7AD7-1033-7B44-A80000000002} /v DisplayName

REG Query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AC7 6BA8-7AD7-1033-7B44-A81000000002} /v DisplayName

REG Query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AC7 6BA8-7AD7-1033-7B44-A81000000003} /v DisplayName"


As you can tell I am looking for the versions on a specific software load. But I have 20000 computers to do this on and instead of looking a all the errors in the script logs, I just want to see which value will actually show up. I have tried getting the FOR and IF statements but with no luck. Hopefully you all can help.


Raven
Squashman's Avatar
Trusted Advisor with 18,706 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
04-Feb-2010, 08:45 AM #2
Redirect the output of the Reg Query to Nul and then check the error level of the previous command.

Code:
REG Query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AC7 6BA8-7AD7-1033-7B44-A93000000001} /v DisplayName >nul
If %errorlevel%==1 echo Registry key not found
Something like that. I am sure you can tweak it to your liking.
raven6988's Avatar
Junior Member with 28 posts.
 
Join Date: Feb 2010
Experience: Intermediate
04-Feb-2010, 09:27 AM #3
Thank you for that. So far it looks like this
@echo off
REG Query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AC7 6BA8-7AD7-1033-7B44-A93000000001} /v DisplayName >nul
If %errorlevel%==0 echo "Program" version 9.3 is installed
If %errorlevel%==1 echo "Program" version 9.3 is not installed.


The only problem I am still having is that it is showing each error if the registry is not there to show the value.

"Error: The system was unable to find the specified registry key or value"

Is still being shown. It has been awhile since I did this level of scripting but is there a way to hide the error messages? If so what command am I looking for?

Thank you for the help thus far.

Raven
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 9,048 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
04-Feb-2010, 09:47 AM #4
Add 2>&1 after >Nul
make sure there is a space in front of the 2
raven6988's Avatar
Junior Member with 28 posts.
 
Join Date: Feb 2010
Experience: Intermediate
04-Feb-2010, 09:58 AM #5
Thank you very much. That fixed my problem and was able to clean up my report significantly. I knew I was forgetting something but its been so long since I did scripting I am rusty.
Squashman's Avatar
Trusted Advisor with 18,706 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
04-Feb-2010, 01:28 PM #6
TheOutcaste is like a hound dog. He sniffs out all my errors and cleans them up.
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 09:41 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.