I would prefer VBS file, but as mentioned by Sonic8: "VB Script is deprecated and will be removed from future version of Window".... I think I have to seriously look into the ACCDB starter app...
And if you want just a one-time test, and if there is an Access icon on the desktop, right-click that icon and click "Open File Location" to see where it is.
you can use this code snippet to return the access path - it reads the registry
Code:
Function GetAccessExePath() As String
Dim ws As Object
Dim folder As String
Set ws = CreateObject("WScript.Shell")
On Error Resume Next
folder = ws.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\" & _
"CurrentVersion\App Paths\MSACCESS.EXE\Path")
On Error GoTo 0
If Len(folder) > 0 Then
If Right(folder, 1) <> "\" Then folder = folder & "\"
GetAccessExePath = folder & "MSACCESS.EXE"
Else
GetAccessExePath = ""
End If
End Function
This returns for 64bit something like this
C:\Program Files\Microsoft Office\root\Office16\MSACCESS.EXE
My example does, but can run in any app that uses vba such as excel or word - the other thing you need to consider is whether the app is in a trusted location (for the app that is running it) otherwise the code won’t run
Note that access to HKLM is not allowed in environments where the user is not a local administrator, unless the app is running with elevated permissions (run as Administrator).
And in this particular case, the same path under HKCU (which such users would have access to) is not populated.
why convert to vbscript when it is to be deprecated?
if you are using a .accdb as a loader app you could use something like
Code:
Select case SysCmd(acSysCmdAccessDir) like "C:\Program Files\*"
case true 'access is 64bit
'install 64bit accde
case false 'access is 32bit
'install 32bit accde
end select
'open accde
'close this accdb
'delete this accdb
Rather than check the installation folder, I would just test for Office bitness using the Win64 compilation constant
Win64 is True when VBA is running in a 64-bit Office environment.
It is False when running in 32-bit Office, even if the operating system itself is 64-bit.
So I just use this function from any Office app that supports VBA.
Rich (BB code):
Function IsOfficex64()
'checks if Office is 32 or 64 bit
#If Win64 Then
IsOfficex64 = "64-bit"
#Else
IsOfficex64 = "32-bit"
#End If
'Debug.Print IsOfficex64
End Function
So adapting the code in the last post, the starter app can just do something like this when it loads:
Rich (BB code):
#If IsOffice64 Then
'install 64bit accde
Else
'install 32bit accde
End If
'open accde
'close this accdb
'delete this accdb
Or do it in one step without the function:
Rich (BB code):
#If Win64 Then
'install 64bit accde
#Else
'install 32bit accde
#End If
'open accde
'close this accdb
'delete this accdb