• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

VBS: Find OS

skace

Lifer
Anyone got anything better than this? It's the best I could come up with however I don't think it's very pretty....

Edit: Friggen hell, attach code sucks...

sub getOS()
set objWMI = getObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colItems = objWMI.execQuery("Select * from Win32_OperatingSystem",,48)
for each objItem in colItems
strOSVer = objItem.buildNumber
strOS = lCase(objItem.caption)
next
select case inStr(1,strOS,"server",1)
case true
select case true
case strOSVer > "6999" and strOSVer < "7999" strOS = "2K9"
case strOSVer > "5999" and strOSVer < "6999" strOS = "2K8"
case strOSVer = "3790" strOS = "2K3"
case strOSVer = "2600" strOS = "2K3"
case strOSVer = "2195" strOS = "2K"
case strOSVer = "1381" strOS = "NT"
case strOSVer = "950" strOS = "95"
case else strOS = "UNK"
end select
case false
select case true
case strOSVer > "6999" and strOSVer < "7999" strOS = "W7"
case strOSVer > "5999" and strOSVer < "6999" strOS = "Vista"
case strOSVer = "3790" strOS = "XP64"
case strOSVer = "2600" strOS = "XP"
case strOSVer = "2195" strOS = "2K"
case strOSVer = "1381" strOS = "NT"
case strOSVer = "950" strOS = "95"
case else strOS = "UNK"
end select
end select
end sub
 
Most version to string functions look like that. You can also grab it from the registry (winver key I think, have to go look). But you'll still be doing some string playing to get a subset.

Also, its 2K8 R2 not 2K9 😉
 
link on google:
Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOSItem in colOperatingSystems
Wscript.Echo "Boot Device: " & objOSItem.BootDevice
Wscript.Echo "Build Number: " & objOSItem.BuildNumber
Wscript.Echo "Build Type: " & objOSItem.BuildType
Wscript.Echo "Caption: " & objOSItem.Caption
Wscript.Echo "Code Set: " & objOSItem.CodeSet
Wscript.Echo "Country Code: " & objOSItem.CountryCode
Wscript.Echo "Debug: " & objOSItem.Debug
Wscript.Echo "Encryption Level: " & objOSItem.EncryptionLevel
dtmConvertedDate.Value = objOSItem.InstallDate
dtmInstallDate = dtmConvertedDate.GetVarDate
Wscript.Echo "Install Date: " & dtmInstallDate
Wscript.Echo "Licensed Users: " & objOSItem.NumberOfLicensedUsers
Wscript.Echo "Organization: " & objOSItem.Organization
Wscript.Echo "OS Language: " & objOSItem.OSLanguage
Wscript.Echo "OS Product Suite: " & objOSItem.OSProductSuite
Wscript.Echo "OS Type: " & objOSItem.OSType
Wscript.Echo "Primary: " & objOSItem.Primary
Wscript.Echo "Registered User: " & objOSItem.RegisteredUser
Wscript.Echo "Serial Number: " & objOSItem.SerialNumber
Wscript.Echo "Version: " & objOSItem.Version
Next
 
Back
Top