Link to home
Start Free TrialLog in
Avatar of upstatenewyorker
upstatenewyorker

asked on

Check the existence of a registry key with a batch file (DOS)

I want to be able to see if a machine has Access 97 on it or Access 2000.  I decided I could check this by looking for the existence of the following key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\9.0\Access

I need to check for the existence of this key via a batch file (DOS).  I would like a way to easily check the existence of this key without using external files, example of which below,

REGEDIT /E file.txt HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\9.0\Access
FIND " " < file.txt

if errorlevel=1 echo Value not found!


This is not a good way of going about it because if the key doesn't exist, the file isn't created, then I would have to code for the existence of the text file.  There has to be an EASIER and CONCISE way of doing this.  Can anyone help?

And, if you can think of a way to check versions of Microsoft Access via a batch file that does not deal with the registry and is EASY and CONCISE, then please share your ideas with me.
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

I would say checking for a different file that exists would be much easier from a batch.  There are plenty of command line utils that could check for registry entries too but you say no external apps.

set version=Acc97
if exist "c:\program files\microsoft office\office\mso9.dll" set version=Acc2000

or another DLL that you know gets installed as part of the build on your machines...

Steve
It seems 8.3 filenames are the order of the day for that though...

if exist "c:\progra~1\micros~1\office\mso9.dll" set version=Acc2000

Steve
Avatar of Lord_Lethris
Lord_Lethris

OK... if I've got my head around this one, you replace the

if errorlevel=1 echo Value not found!

with the following, replacing the [??] entries with whatever is needed.

=========================

if errorlevel=1 goto :ERR
GOTO :END
:ERR
copy [from wherever]\file.txt [to wherever]
REM this file.txt will contain text like ACCESS Not FOUND
:END

=========================

I hope thats what your on about, that way if the exsistance of ACCESS isn't found then it will copy a pre made .txt file with whatever you want in it to wherever your saving the .txt files too.

(Phew!)
Steve's right about there being plenty of apps out there that will search for software.  If your worried about licencing issues, there are freeware ones.  Or for $200 (dunnow what this might be in other contries) you can get EZ-Audit.  Excelent package, and you can run it on login without having to install it on all the PC's.  the evaluation copy lets you run audits BUT you can only View 5 PC's at a time.

http://www.ezaudit.net/reg/default.htm

take a look. We brought this in the end, 'cos in the long run it saved us a hell of a lot of work over the years.
Avatar of upstatenewyorker

ASKER

I had already thought about the mso9.dll, however, our departments have Office 97 for Access, Excel and Powerpoint.  They also have Outlook 2000, which I believe dumps the dll on the hard drive as part of the installation.  So, then that's when I looked into the registry issue.  This is very complicated, that's for sure.  Is there another file on the hard drive which is indicative of an Access 97 or 2000 installation?

I appreciate all your help. I really do.
Also, what is the dll for Access XP?  Does anyone know?
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Delete question, refund points
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Geoff Lilley
EE Cleanup Volunteer
ASKER CERTIFIED SOLUTION
Avatar of SpazMODic
SpazMODic

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial