Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When using a batch file, is there a command I can use to check if Access 2010 Runtime is currently installed and if is not, then invoke it's installation?

This will be used on both Windows 7 and Windows XP.

Edit: looking for a way to check for the installation of the program without knowing where the files are put when Access Runtime is installed.

share|improve this question

3 Answers 3

up vote 1 down vote accepted

You can read the information from the registry:

reg.exe QUERY HKLM\SOFTWARE\Classes\Access.Application.14\shell\Open\command /ve

This commands reads the MSAccess.EXE path from the registry. You just need to save it into a variable and then remove the garbage around it. That can be done using "for" command.

share|improve this answer

I'm surprised you didn't find that command
IF NOT ACCESS2000RunTimeInstallation RUN ACCESS2000RuntimeInstallation
;-)

But anyhow,

Here is the principle.

I have a file called a.a and a directory called c:\windows. I don't have a file called a.b and I don't have a directory called c:\windows1

One can say

if exist a.a c:\program\program.exe

In the examples below, you can replace "echo here", with the path of a program

Now find out what files the access 2000 installation thing puts in the hard drive and pick a unique one, or a directory it makes, and use that for your IF statement.

C:\>if exist a.a echo here
here

C:\>if exist a.b echo here

C:\>if exist c:\windows\nul echo here
here

C:\>if exist c:\windows1\nul echo here

C:\>

Update-

You can also check the registry

As an example, whatever the program, one place you might see the thing is in Add/Remove programs. Here is the place in the registry where that is stored. You can run that command and scroll through that just to get an idea of the command

C:\>reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Unins
tall | more

One program listed is Windows Media Player, which you'd have too

C:\>reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Unin
stall\Windows Media Player"

! REG.EXE VERSION 3.0

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Windows M
edia Player
    DisplayName REG_SZ  Windows Media Player 10
    UninstallString     REG_SZ  "C:\Program Files\Windows Media Player\Setup_wm.
exe" /Uninstall
    DisplayIcon REG_SZ  C:\Program Files\Windows Media Player\wmplayer.exe
    ParentKeyName       REG_SZ  OperatingSystem
    ParentDisplayName   REG_SZ  Windows Updates

C:\>

That "successful" reg query command sets ERRORLEVEL to 0, meaning no error.

C:\>echo %errorlevel%
0

If the key didn't exist e.g. I look for Windows Media Playerr (notice the extra r)

C:\>reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Unin
stall\Windows Media Playerr"

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

C:\>echo %errorlevel%
1

C:\>

When %errorlevel% is >=1 then it means error.

So you can test IF %errorlevel%==0 You can test IF NOT %errorlevel%==0 You can use an ELSE

The other syntax for testing ERRORLEVEL, don't do if errorlevel 0 (silly) 'cos that asks the value is >=0. You say IF ERRORLEVEL 1 (i.e. if the value is >=1) , or IF NOT ERRORLEVEL 1 (i.e. if the value is not >=1 i.e. if the value is 0 or less - and I doubt it could ever be less). Or you use the %errorlevel%.

share|improve this answer
    
Thank you for this input. I understand how the IF EXIST command works and use it to check for some other files. What if I don't know where the installer puts things or what files are unique to Access 2010 Runtime? –  CharlieRB Apr 25 '12 at 12:55
1  
you can check the registry too, see my update. If you don't know what files or registry entries it makes, then you could run an uninstaller, monitor the installation or before and after the installation, and see what files or registry entries it puts on there, and check for a few. Then you can be sure it's unique! Or, you could see what registry entry it makes in Add/Remove programs. That's probably unique. –  barlop Apr 25 '12 at 15:00

As an alternative to the registry, if you want to check if it's installed, wmic can do that. The commands for checking installed programs typically take a bit of time to run, however.

wmic product where "name like 'WhateverAccessRuntimeIsCalled'" get version

To check what it's actually called (you need exact name) and correct version, install it on your own computer. Then, on your own computer:

wmic product get name,version>programlist.txt && notepad.exe programlist.txt && del programlist.txt

You can then, in the batch file, run the query command:

setlocal EnableDelayedExpansion

for /f "skip=1 tokens=1 usebackq delims=." %%a in (`wmic product where "name like 'WhateverAccessRuntimeIsCalled'" get version`) do (
    if /i "!_versionstring!" LSS "%%a" (
        set _versionstring=%%a
    )
)

if /i "%_versionstring%" LSS "WhateverTheMajorVersionNumberShouldBe" (
    echo It's not installed
) else (
    echo It is installed
)

Office 2010 has a major version number (the first number, separated by dots) of 14. Of course, if the program name has "2010" in it, there isn't really a need to check the version number. If the program doesn't exist, %_versionstring% will be empty.

Checking the registry is definitely faster, but I would argue this is the 'correct' way to check if a MSI based program is installed.

share|improve this answer
    
wmic is a nice idea. But AFAIK wmic is not available by default on Windows XP. –  Robert Apr 26 '12 at 15:17
    
@Robert It isn't? Ok, scrap this idea then. Checking the registry, perhaps the uninstall keys, would be the way to go then. –  Bob Apr 26 '12 at 22:23
    
I checked the availability of WMIC on XP and I have to say that I was partly wrong. WMIC came with SP2 but it is only installed if it is an XP Professional version. Therefore WMIC is only unavailable on XP Home. –  Robert Apr 27 '12 at 8:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.