OS Detection (1 Viewer)

Guus2005

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

Thanks!
 

Minty

AWF VIP
Local time
Today, 10:32
Joined
Jul 26, 2013
Messages
10,369
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.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:32
Joined
May 7, 2009
Messages
19,230

Guus2005

AWF VIP
Local time
Today, 11:32
Joined
Jun 26, 2007
Messages
2,641
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
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:32
Joined
May 7, 2009
Messages
19,230
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
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:32
Joined
Feb 28, 2001
Messages
27,156
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.
 

deletedT

Guest
Local time
Today, 10:32
Joined
Feb 2, 2019
Messages
1,218
I was just wondering what will happen if I run this code from a non-windows OS:
?GetEnviron("OS")
 

Isaac

Lifelong Learner
Local time
Today, 02:32
Joined
Mar 14, 2017
Messages
8,777
Well you can cross out android and chromebook..
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:32
Joined
Feb 28, 2001
Messages
27,156
@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.
 

deletedT

Guest
Local time
Today, 10:32
Joined
Feb 2, 2019
Messages
1,218
Sorry, I have a GetEnviron function using Environ statement. I meant Environ. Thanks for correcting.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:32
Joined
May 7, 2009
Messages
19,230
there is already a Mac version of Office.
 

deletedT

Guest
Local time
Today, 10:32
Joined
Feb 2, 2019
Messages
1,218
there is already a Mac version of Office.

Access is not included in Office for mac bundle



2020-08-21_18-24-43.jpg
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:32
Joined
May 7, 2009
Messages
19,230
too bad.. but still you can do VBA with the rest and find out what OS?

while here Access is listed:

.
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:32
Joined
Sep 21, 2011
Messages
14,254
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

MVP / VIP
Local time
Today, 10:32
Joined
Jan 14, 2017
Messages
18,211
@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
 

Guus2005

AWF VIP
Local time
Today, 11:32
Joined
Jun 26, 2007
Messages
2,641
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!
 

Minty

AWF VIP
Local time
Today, 10:32
Joined
Jul 26, 2013
Messages
10,369
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

Top Bottom