What is the best way to check in a macro if its running on windows or linux?
I want to modify shell command to work with either bash or cmd.
What is the best way to check in a macro if its running on windows or linux?
I want to modify shell command to work with either bash or cmd.
This is from Andrew’s OOME:
'Listing 173. Display the GUI type as a string.
Sub DisplayGUIType()
Dim s As String
Select Case GetGUIType()
Case 1
s = "Windows"
Case 2
s = "OS/2" ' Set in the source code, but no longer documented.
Case 3
s = "Mac OS" ' Used to be documented, never supported, I expect Mac to return 4.
Case 4
s = "UNIX"
Case Else
s = "Unknown value " & CStr(GetGUIType()) & CHR$(10) &_
"Probably running in Client/Server mode"
End Select
MsgBox "GUI type is " & s, 0, "GetGUIType()"
End Sub
' The value -1 is returned if the type is not known, but that is not specifically documented. This probably
'means that you are running in a client / server mode, but, I have not checked that.
Thanks, GUI type just didn’t register when I was looking at the index for OS type.
I recommend the following Basic code:
Option Explicit
Sub Main : MsgBox OSName : End Sub
Function OSName As String
''' Return platform name as "MAC", "UNIX", "WIN" '''
With GlobalScope.Basiclibraries
If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")
End With
Dim keyNode As Object ' com.sun.star.configuration.ConfigurationAccess'
keyNode = Tools.Misc.GetRegistryKeyContent("org.openoffice.Office.Common/Help")
OSName = keyNode.GetByName("System")
' inferred from "Tools.UCB.ShowHelperDialog" '
End Function ' (Tools).OSName '
Enjoy !