Ask Your Question

Macro check if windows or linux

asked 2016-08-22 17:49:07 +0200

mark_t gravatar image

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.

edit retag flag offensive close merge delete


Similar question is here.

EasyTrieve gravatar imageEasyTrieve ( 2017-05-11 21:21:35 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2016-08-22 22:42:37 +0200

paul1149 gravatar image

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.
edit flag offensive delete link more


Thanks, GUI type just didn't register when I was looking at the index for OS type.

mark_t gravatar imagemark_t ( 2016-08-22 23:19:07 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-08-22 17:49:07 +0200

Seen: 220 times

Last updated: Aug 22 '16