On a side note, I always wondered why MS never provided an easy api function to get the friendly name of the OS, for example, "Windows 7 Ultimate", instead of making people jump through hoops with testing this and that condition or digging this and that out of a return from something else. You would think that with all the hub bub they go through with names for their operating systems that there would be a simple call to something like "GetOperatingSystemFriendlyName()" in the api without having to jump through hoops to get it. Its almost like they don't want people to be able to get it easily. Yeah, you can do it via reading the registry but that's not without its own pitfalls and its still jumping through hoops.
Anyway, harkening back to the WMI method earlier in the thread, one could also do this using the command prompt.
Quick and dirty code below:
Code: Select all
Procedure.s GetOSNameInfo()
Compilertrdns = RunProgram("wmic.exe", " os get Caption", "", #PB_Program_Hide|#PB_Program_Open|#PB_Program_Read)
Outns$ = ""
If Compilertrdns
While ProgramRunning(Compilertrdns)
Outns$=ReadProgramString(Compilertrdns)
keepdns$ = keepdns$ + Outns$ + #CRLF$
Wend
CloseProgram(Compilertrdns)
EndIf
name$ = RemoveString(keepdns$, Chr(10), #PB_String_NoCase, 1)
name$ = RemoveString(name$, Chr(13), #PB_String_NoCase, 1)
name$ = Trim(RemoveString(name$, "Caption", #PB_String_NoCase, 1))
Compilertrdnsx = RunProgram("wmic.exe", " path Win32_OperatingSystem get version", "", #PB_Program_Hide|#PB_Program_Open|#PB_Program_Read)
Outnsx$ = ""
If Compilertrdnsx
While ProgramRunning(Compilertrdnsx)
Outnsx$=ReadProgramString(Compilertrdnsx)
keepdnsx$ = keepdnsx$ + Outnsx$ + #CRLF$
Wend
CloseProgram(Compilertrdnsx)
EndIf
version$ = RemoveString(keepdnsx$, Chr(10), #PB_String_NoCase, 1)
version$ = RemoveString(version$, Chr(13), #PB_String_NoCase, 1)
version$ = Trim(RemoveString(version$, "Version", #PB_String_NoCase, 1))
Compilertrdnsy = RunProgram("wmic.exe", " path Win32_OperatingSystem get CSDVersion", "", #PB_Program_Hide|#PB_Program_Open|#PB_Program_Read)
Outnsy$ = ""
If Compilertrdnsy
While ProgramRunning(Compilertrdnsy)
Outnsy$=ReadProgramString(Compilertrdnsy)
keepdnsy$ = keepdnsy$ + Outnsy$ + #CRLF$
Wend
CloseProgram(Compilertrdnsy)
EndIf
sp$ = RemoveString(keepdnsy$, Chr(10), #PB_String_NoCase, 1)
sp$ = RemoveString(sp$, Chr(13), #PB_String_NoCase, 1)
sp$ = Trim(RemoveString(sp$, "CSDVersion", #PB_String_NoCase, 1))
Compilerprodtyp = RunProgram("wmic.exe", " path Win32_OperatingSystem get ProductType", "", #PB_Program_Hide|#PB_Program_Open|#PB_Program_Read)
Outprodtyp$ = ""
If Compilerprodtyp
While ProgramRunning(Compilerprodtyp)
Outprodtyp$=ReadProgramString(Compilerprodtyp)
keepprodtyp$ = keepprodtyp$ + Outprodtyp$ + #CRLF$
Wend
CloseProgram(Compilerprodtyp)
EndIf
prodtyp$ = RemoveString(keepprodtyp$, Chr(10), #PB_String_NoCase, 1)
prodtyp$ = RemoveString(prodtyp$, Chr(13), #PB_String_NoCase, 1)
prodtyp$ = Trim(RemoveString(prodtyp$, "ProductType", #PB_String_NoCase, 1))
prdtp = Val(Trim(prodtyp$))
Select prdtp
Case #VER_NT_WORKSTATION
prdtype$ = "Workstation"
Case #VER_NT_DOMAIN_CONTROLLER
prdtype$ = "Domain Controller"
Case #VER_NT_SERVER
prdtype$ = "Server"
Default
prdtype$ = "Unknown Type"
EndSelect
osnamever$ = name$ + " " + version$ + " - " + prdtype$ + " - " + sp$
ProcedureReturn osnamever$
EndProcedure
Debug GetOSNameInfo()
Wish my windows 8 machine was up and running

, hard drive failures are a pain, but..... anyway here on on Windows 7 64 bit it produces:
Microsoft Windows 7 Ultimate 6.1.7601 - Workstation - Service Pack 1
My understanding though is that wmi via the command prompt also gives the correct version information for Windows 8 and 8.1.
The world and human nature was screwed up before I was born. It's not my fault and I'm just stuck with trying to deal with the mess left behind, so don't blame me.