Just create a new document on your desktop and rename it to GetOS.vbs
Right click and edit, paste the code below and save it. Double click and run it to display your Windows Version. Good code to use in batch or other functions.
msgbox GetOS
Function GetOS()
'Requires WSH 5.6
'CMD window will flash as there is no way to supress it when using exec.
Dim WshShell : Set WshShell = CreateObject("WScript.Shell")
Dim strVer : set strVer = WshShell.exec("%comspec% /c ver")
Dim sResults
sResults = strVer.stdout.readall
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 InStr(sResults, "Version 6.0") > 1 : GetOS = "Vista"
Case InStr(sResults, "Version 6.1") > 1 : GetOS = "W7"
Case Else : GetOS = sResults
End Select
End Function
No comments:
Post a Comment