Macro check if windows or linux [closed]
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.
First time here? Check out the FAQ!
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.
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 !
Asked: 2016-08-22 17:49:07 +0100
Seen: 577 times
Last updated: May 21 '19
Why has the profile directory location changed since LibreOffice 3.5? [closed]
Why are there LibreOffice help packs if F1 already provides web help? [closed]
Problem with new download [closed]
Error in fetching Git repository [closed]
Installation failure on Windows 7 [closed]
Where can I find documentation to custom/silent install 3.5 msi? [closed]
Windows installer fails [closed]
Is there an equivalent "Send To OneNote" feature? [closed]
Why do LibreOffice attachments become 2 bytes sized files in Outlook Webmail? [closed]
Similar question is here.