Adjusted as of April, 2022
Had been using
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\MSACCESS.EXE\Path
but it started failing at a couple clients today 4/8/2022
I adjusted the code to check another location:
HKEY_CLASSES_ROOT\Access.MDBFile\shell\New\command\
Here is the code
Private Function getMSAccessPath()
Dim WSHShell
Dim RegKey
Dim Rtn
Set WSHShell = WScript.CreateObject("WScript.Shell")
on error resume next
RegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\MSACCESS.EXE\Path"
Rtn= WSHShell.RegRead(RegKey)
if err.number <> 0 then
RegKey = "HKEY_CLASSES_ROOT\Access.MDBFile\shell\New\command\"
Rtn= WSHShell.RegRead(RegKey)
Rtn = left(Rtn,instr(Rtn, "MSACCESS.EXE")-1)
Rtn = mid(Rtn, 2)
end if
on error goto 0
getMSAccessPath = Rtn
End Function