msgbox GetOS
Function GetOS()
'Will work with most versions of WSH.
'CMD window will not display.
Const OpenAsASCII = 0
Const FailIfNotExist = 0
Const ForReading = 1
Dim WshShell : Set WshShell = CreateObject("WScript.Shell")
Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
Dim sTemp, sTempFile, fFile, sResults
sTemp = WshShell.ExpandEnvironmentStrings("%TEMP%")
sTempFile = sTemp & "\runresult.tmp"
WshShell.Run "%comspec% /c ver >" & sTempFile, 0, True
Set fFile = FSO.OpenTextFile(sTempFile, ForReading, FailIfNotExist, OpenAsASCII)
sResults = fFile.ReadAll
fFile.Close
FSO.DeleteFile(sTempFile)
Select Case True
'Add more info to the 98 and 95 to get the specific version. i.e. 98SE 95 a,b,or c
Case InStr(sResults, "Windows 95") > 1 : GetOS = "W95"
Case InStr(sResults, "Windows 98") > 1 : GetOS = "W98"
Case InStr(sResults, "Windows Millennium") > 1 : GetOS = "WME"
Case InStr(sResults, "Windows NT") > 1 : GetOS = "NT4"
Case InStr(sResults, "Windows 2000") > 1 : GetOS = "W2K"
Case InStr(sResults, "Windows XP") > 1 : GetOS = "WXP"
Case Else : GetOS = "Unknown"
End Select
End Function
<message edited by mbouchard on Friday, September 16, 2005 12:17 AM>