1.

Solve : REG COMPARE HELP?

Answer»

How do I check for a value in the registry and based upon weather the registry value exist allow a PROGRAM to be installed. If registry value does exist, don't install a program. (How do I get the return valve from the REG COMPARE into a varable.)Use for then reg query, the file wont be created if the key doesent exist because reg query creates an error..


for /f "tokens=1*" %%a in ('reg query HKCR\exefile\shell\open\command\sss') do echo %%a>>r2
if not exist %cd%\r2 goto installreg query HKCR\exefile\shell\open\command\sss || echo key does not existThank you very much. I used the double pipe command.
This is the opposite

reg query HKCR\exefile\shell\open\command\sss && echo key existsIs there a way to prevent the command results from being DISPLAYED on the screen? /QQuote from: mrische1 on JUNE 05, 2008, 10:15:29 AM

How do I get the return valve from the REG COMPARE into a varable.

The Return Code is returned by the system as a variable already (Errorlevel):
0 - Successful 1 - Failed.
You can use the if errorlevel - goto in your batch file to utilize the results. Test for errorlevel 1 first. If true goto an error message and exit. If errorlevel 1 is false, then the reg query was successful and you can proceed with the installation.

Quote from: mrische1 on June 06, 2008, 11:28:17 AM
Is there a way to prevent the command results from being displayed on the screen? /Q

I couldn't find any way, but adding the code &cls to the line will clear the screen within a few nanoseconds, so that most users will not be able to see the output. (Warning, It may still be possible to capture the output while using the cls.)

The following code tests for the existence of a specific string value name.
[HKEY_CURRENT_USER\Software\7-Zip] "Test"
If you need to check for a specific string value, it may be a bit more difficult.
(You can eliminate the notes, echo's & pauses after testing & debugging.)

Oops: The following code has been edited as of 06/08/2008 1:15 AM EST.
The original posted code did the opposite of what mrische1 requested.
It went to Don't_Instl, when it should have gone to Install. I read the request wrong.

Code: [Select]@echo off

:: Tests for the existense of string value name
reg query HKCU\Software\7-Zip /v Test&cls
if errorlevel 1 goto Install

:: Add Installation Error Message here. IE:
echo Sorry ... The system cannot install your program as desired.
pause >nul
goto End

:Install
:: Add Installation code here. IE:
echo Installation proceeding as requested.
pause >nul

:End
exitQuote from: llmeyer1000 on June 07, 2008, 08:53:19 AM
adding the code &cls to the line will clear the screen within a few nanoseconds

Not without seriously distorting the meaning of "few".
Quote from: Dias de verano on June 07, 2008, 09:06:32 AM
Not without seriously distorting the meaning of "few".

WOW! Dias, I might have expected that out of some others, but I didn't expect you to be so picky. Do you really need to get so creative to increase your post count?

I'm sorry I didn't do any research on the ELAPSED time between lines in a batch file, the processor refresh rate, the refresh rate on the average video card, and any other factors involved!
The inaccuracy in my use of the word "few" might have actually made a difference on a 286, but on most computers in use today the difference is almost neglible, which is what the phrase was meant to convey. (I would have thought that most people would have realized that.) Besides, I think the warning that I posted should have been sufficient to cover the nanosecond error. Quote
(Warning, It may still be possible to capture the output while using the cls.)

No need to get sore, not to say nasty, over being caught out about an elementary error.

A nanosecond is a billionth of a second. Quote from: Dias de verano on June 07, 2008, 11:42:23 AM
A nanosecond is a billionth of a second.

I think most of us know that already. Your posts usually a bit more useful than trying to finding "error" in someones choice of wording. The point was simply that the output would be displayed for only a very brief period of time. (two shakes of a LAMB's tail, a few nanoseconds, a very short period of time.)

I really doubt that the writer of this article meant a few nanoseconds literally any more than I did:
Take a Few Nanoseconds to Explore the Roots of ComputingOk, maybe I went over the top there, but it does bug me when people use terms like that loosely. As in off by a factor of 10,000. Other ones that bug me are using the phrase light year as a measure of time, or saying that using paper "kills rain forests" (it doesn't). I had to research "over the top" before I could reply. Were you referring to the military definition, leaving a safe condition for an unsafe one, the arm wrestling move, or the one referring to "excess, particularly outrageous behaviour or hyperbole."
http://en.wikipedia.org/wiki/Going_over_the_top

If it was the latter, I suppose I was guilty also, particularly in Reply #8. I may have overreacted a bit due to being too thin skinned at times. I really hope that "thin skinned" isn't another one of those expressions that get on your nerves. If it is then I'll probably just have to do something drastic, like reformat my HD. Opps, I just did it again. Sorry about that! I just couldn't resist.

I hope mrische1 gets back with us soon and gets this thread back on track. Any more deviation on our part, & we may soon be accused of hijacking!

Oops: Now here's an error worth fixing. In Reply #6 the posted code has been edited as of 06/08/2008 1:15 AM EST.
The original posted code did the opposite of what mrische1 requested.
It went to Don't_Instl, when it should have gone to Install.

Quote from: mrische1 on June 05, 2008, 10:15:29 AM
If registry value does exist, don't install a program.

I read the request wrong. I read it as if "Do not install unless the value does exist.


Discussion

No Comment Found