Check version of MS Access with Batch File? (1 Viewer)

Local time
Today, 02:58
Joined
Feb 25, 2008
Messages
410
Is there any way to program a batch file to check the version of Microsoft Access installed on a PC?
 
Local time
Today, 02:58
Joined
Feb 25, 2008
Messages
410
Well, I've been searching google and a lot of other places, but still haven't found an answer.
I'm pretty sure I'll have to write something myself, but does anybody have any experience with this?
 
Local time
Today, 04:58
Joined
Mar 4, 2008
Messages
3,856
What are you going to do with the value once you have it?

I would simply put an Auto_Open subroutine in an Excel sheet and use automation to get the answer (possibly write to a text file). But that may not work for you, depending on what you're using it for.
 
Local time
Today, 02:58
Joined
Feb 25, 2008
Messages
410
Well, once the script obtains a value (perhaps a version number, or something else that is unique to each version of Access) the script can execute the appropriate batch file which will launch the right copy of the front-end. (each version of the front-end has it's own batch file)

One other issue is that some computers here at work have office 2003 installed, but only have Access '97. So I can't determine the version of Access by the version of Office installed. Instead, I'll have to specifically find the verion of Access installed.
 
Local time
Today, 04:58
Joined
Mar 4, 2008
Messages
3,856
If it's a Windows/DOS batch file, the method I described could help you. You'll, no doubt, want to use several batch files, one to get the value from Excel, one to extract that value from the text file and call the third, and one to do whatever it is you want done.
 
Local time
Today, 02:58
Joined
Feb 25, 2008
Messages
410
Through some further research, I've found that each version of Access has a unique registry key value;

HKEY_CLASSES_ROOT\.mdb\Access.Application.8 for Access 97
HKEY_CLASSES_ROOT\.mdb\Access.Application.9 for Access 2000
HKEY_CLASSES_ROOT\.mdb\Access.Application.10 for Access XP

I'm going to start looking into reading the registry from within a batch file.
If anybody has some good tips, let me know!

GeorgedWilkinson, Thanks for your help, I wouldn't have thought of this without you.
 
Local time
Today, 04:58
Joined
Mar 4, 2008
Messages
3,856
Sounds like you may be able to use regedit /E from your script to get the data you need. Looks like you're well on your way to solving this one.
 
Local time
Today, 02:58
Joined
Feb 25, 2008
Messages
410
Yes, I am well on my way!

I have staretd using REG.EXE to query the registry and store the version in the VERSION variable.

Now all I need to do is implement that variable into the batch file's decision making routine, to run the correct .mde.

If anybody wants to run this code, go right ahead. Just copy the code in green.

Code:
@ ECHO OFF
CLS
ECHO.
ECHO Starting the PIR Database. This should only take a few seconds.
ECHO.

  REM Note that the variables and the batch file name MUST be customised for each database

  REM ***** THE VARIABLES ******

  REM PGRM is the variable for the file name of your current Front_End.mdb.
  REM When updating the version of the Front End simply change PGRM and resave the batch file
  REM (Note: PGRM must also fit the LOCDEL naming pattern below so old versions delete OK.)
  REM LOCDIR is the directory on the Client PC that will hold the working version of PGRM
  REM FILNM is the prefix of the filename since a space is not recognised in the "set LOCDEL=" function.
  REM LOCDEL is the pattern of files to delete in LOCDIR if the latest version 
  REM of PGRM can't be found (Note that the value of LOCDEL is case sensitive)
  REM (Vital Note: TRIPLE CHECK the items you assign to LOCDIR and LOCDEL. Delete is 
  REM VERY unforgiving.  NEVER EVER set LOCDIR to just C: or LOCDEL to *.*)
  REM MSACC is the dos path to MS Access on the local PC. 
  REM SRVDIR is the directory on the Server to get the latest version of PGRM from.
  REM WKGRP is the location of the access secure workgroup to use.  (Note. Leave WKGRP blank
  REM if you are using the standard MSAccess work group)
  REM HKPATH is the directory of MouseHook.dll (%WinDir%\System\)
  REM HKFILE is the MouseHook.dll file
[COLOR="SeaGreen"]
  REM Check "HKEY_CLASSES_ROOT\.mdb\(Default Value)" for the version of Access installed;
  REM "Access.Application.8" for Access 97
  REM "Access.Application.9" for Access 2000
  REM "Access.Application.10" for Access XP[/COLOR]

  REM ***** THE VARIABLES *****

[COLOR="SeaGreen"]FOR /F "tokens=2* delims=	 " %%A IN ('REG QUERY HKEY_CLASSES_ROOT\.mdb /ve ') DO SET VERSION=%%B
ECHO %VERSION%
PAUSE[/COLOR]

SET PGRM="PIR CSC V2.4.mde"

SET LOCDIR="C:\Documents and Settings\%username%\WINDOWS"

SET FILNM="PIR "

SET LOCDEL=%FILNM%CSC*.*.mde

SET MSACC="C:\Program Files\Microsoft Access97\MSACCESS.EXE"

SET SRVDIR="\\csc-fs\CSC-CMS\PIR-DB\Back-End\97"

SET WKGRP=

SET HKPATH=%WinDir%\System

SET HKFILE="MouseHook.dll"

  REM ***** COPY YOUR CURRENT FRONT END TO THE PC CLIENT ***** 
  REM Check if the local directory LOCDIR exist's, if not then create it
  REM If current version of PGRM does not exist in LOCDIR then:
  REM 1. Keep the customers happy!
  REM 2. Delete any old versions of PGRM from LOCDIR,
  REM 3. Copy the new version of PGRM to LOCDIR

if not exist %LOCDIR% md %LOCDIR%
if not exist %LOCDIR%\%PGRM% echo Updating to the latest version of %PGRM%
if not exist %LOCDIR%\%PGRM% del %LOCDIR%\%LOCDEL%
if not exist %LOCDIR%\%PGRM% copy %SRVDIR%\%PGRM% %LOCDIR%\%PGRM%
if not exist %HKPATH%\%HKFILE% copy %SRVDIR%\%HKFILE% %HKPATH%\%HKFILE%

START /MAX %MSACC% %WKGRP% %LOCDIR%\%PGRM%
 
Last edited:
Local time
Today, 02:58
Joined
Feb 25, 2008
Messages
410
Thanks for posting the solution!!!

LOL. It's funny you say that.
The database I'm building is a repository where customer's questions get answered. All too often, the original person finds the answer themselves and don't post it in the record for eveybody else. It's becoming a pet-peeve of mine. :p
 

boblarson

Smeghead
Local time
Today, 02:58
Joined
Jan 12, 2001
Messages
32,059
The only limitation of this, is that if you are running MULTIPLE versions of Access, it will only return the LAST version that was run.
 
Local time
Today, 02:58
Joined
Feb 25, 2008
Messages
410
Good to know!

I think I'll be okay though. Whatever version the user used last is the version that the batch file will execute; Frankly, I don't care what version the user used last, just as long as I don't have to distribute different versions one-by-one, and the user doesn't have to think.

The best advantage I see, is if the user gets upgraded to a later version (as long as I have an .mde built for it) the batch file will go get the correct version the next time they try to access the link. (which saves me a phone call!)
 

undrline

New member
Local time
Today, 02:58
Joined
Aug 28, 2008
Messages
1
If the user's privileges to those registry keys are restricted, and you're operating under the user's privileges, wouldn't this be a problem?
 
Local time
Today, 02:58
Joined
Feb 25, 2008
Messages
410
Probably, but it seems that the group policy on our users does not restrict any registry keys. Hopefully it stays that way.
 

Users who are viewing this thread

Top Bottom