OS Detection

Guus2005

AWF VIP
Local time
Today, 19:20
Joined
Jun 26, 2007
Messages
2,642
I want to be able to detect if my application runs on Windows, Linux, Apple, Chromebook, Android, ...

Thanks!
 
From Access? As far as I know Access only runs on Windows?
If it's on a VM or RDP then you'll only be able to get the underlying OS, not the host.
 
How can i run a javascript script from vba and use the return value?

This little gem i can use.
Code:
#if Mac then
  'Run on Mac
#else
  'Run on PC
#endif
 
is this in MSA?
Code:
Public Function WhichOS()
    Dim strOS As String
#If Mac = 1 Then
    strOS = "Mac"
#End If
#If Win32 = 1 Then
    strOS = "Win32"
#End If
#If Win64 = 1 Then
    strOS = "Win64"
#End If
    WhichOS = strOS
End Function
 
I'm not sure if ANY function exists that is uniform across all operating systems for that purpose. Normally, to know on what you are running, you must make a system service call or an O/S call or some other name for the same concept - asking the O/S something. But the very mechanism you would choose to make that call presupposes that you already know enough to know which call to use. I.e. it is a two-pass algorithm. Even the trick of reading the registry requires you to know that there IS a registry to read.

Arnel's WhichOS function would work OK until you turned your app into an .MDE or .ACCDE, because the #IF construct is a compile-time operation. I can find no intrinsic function in Access to do this, and the ability to use a declared API call presupposes that you know that call would be available to be used in the first place.

Having said that, you MIGHT be able to make SOME inferences using the directory functions to scan for specific directories that would be present for each O/S - like if you see /system/windows32 then you know you are on a Windows box. But I don't know what other folders to expect for those other operating systems.
 
I was just wondering what will happen if I run this code from a non-windows OS:
?GetEnviron("OS")
 
Well you can cross out android and chromebook..
 
@Tera, in Access that is "Environ" not "GetEnviron" - and what that actually does is it looks at some environmental variables. For that to work, something would have to define an environmental variable called "OS" - and that is not a common action. I'm not sure that anything would come back for a non-windows machine because "Environment" variables are a holdover from MS-DOS and early Windows - back from before the time that Windows used the registry almost exclusively vs. .INI files.
 
Sorry, I have a GetEnviron function using Environ statement. I meant Environ. Thanks for correcting.
 
there is already a Mac version of Office.
 
there is already a Mac version of Office.

Access is not included in Office for mac bundle



2020-08-21_18-24-43.jpg
 
too bad.. but still you can do VBA with the rest and find out what OS?

while here Access is listed:

.
 
too bad.. but still you can do VBA with the rest and find out what OS?

while here Access is listed:

.
It states ' Office 2019 is a one-time release and won’t receive future feature updates. '

Bit of a dead end perhaps?
 
@isladogs While MS-Access is designed to run on windows, there are several ways to use it under other OSes.
For Mac:
  • Bootcamp
  • Virtualisation
  • Emulation
  • Wine
Source:
.


Hi Tera
Yes I'm aware of that but with VMs, Bootcamp etc you are running it in a separate Windows 'sandbox'.
So the detected OS will still be Windows in each case.

AFAIK, there has never been a version of Access for Mac, Android, Linux etc and I can't see any reason why there would be in the future
 
Thanks for all the answers.

When you can't execute code you can't detect anything. The site from where the application can be downloaded clearly states that only Windows OS is supported.
I was looking for a nicer way to inform the user. But apparantly that is not possible.
Perhaps we can modify the download page to inform the user not to download the application or to hide the download alltogether.

Edit: And i hope that Office will be available for Lunix very soon!
 
I'm guessing that if you made an installer package for your app it would simply warn the user it can't be installed on that platform and exit?
 

Users who are viewing this thread

Back
Top Bottom