Running application from registry key path

This post for my reference:
I had a different version of MSAccess application and I had to run the application using Powershell script. The path of the application differs from computer to computer, since mine x64 bit the application resides in Program Files(x86) folder and in some other x32 bit machines the application is in Program Files. Moreover with different versions of Access the folder structure changes.

With the registry key it will target the latest version installed on your machine

@ECHO OFF
for /f "tokens=3*" %%x in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\MSACCESS.exe" /v PATH') do set ACCESSM="%%x %%y"
"%ACCESSM%\MSACCESS.EXE \"Database Path\" /X macro-name"
@ECHO ON

Leave a Reply

Your email address will not be published. Required fields are marked *