I want to identify an OS, but not by a String
as I want to map this as an ID.
Several ways of going about this, so my question is:
Does anyone have a list of all the possible answers this produces?
var name = (from x in new System.Management.ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem").Get().OfType<System.Management.ManagementObject>()
select x.GetPropertyValue("Caption")).FirstOrDefault();
Or, is there a way to reverse lookup the Caption
field based on any other field?
By looking at https://msdn.microsoft.com/en-us/library/windows/desktop/aa394239(v=vs.85).aspx there doesn't seem to be enough info to recreate the Caption
from all the other properties.
Here's a sample of this result on my machine:
BootDevice: \Device\HarddiskVolume1
BuildNumber: 10586
BuildType: Multiprocessor Free
Caption: Microsoft Windows 10 Pro N
CodeSet: 1252
CountryCode: 1
CreationClassName: Win32_OperatingSystem
CSCreationClassName: Win32_ComputerSystem
CSDVersion:
CSName: DESKTOP-6UJPPDS
CurrentTimeZone: 120
DataExecutionPrevention_32BitApplications: True
DataExecutionPrevention_Available: True
DataExecutionPrevention_Drivers: True
DataExecutionPrevention_SupportPolicy: 2
Debug: False
Description:
Distributed: False
EncryptionLevel: 256
ForegroundApplicationBoost: 2
FreePhysicalMemory: 2027936
FreeSpaceInPagingFiles: 4486600
FreeVirtualMemory: 2611432
InstallDate: 20151223101608.000000+120
LargeSystemCache:
LastBootUpTime: 20160215101020.112003+120
LocalDateTime: 20160225114508.446000+120
Locale: 0409
Manufacturer: Microsoft Corporation
MaxNumberOfProcesses: 4294967295
MaxProcessMemorySize: 137438953344
MUILanguages: System.String[]
Name: Microsoft Windows 10 Pro N|C:\WINDOWS|\Device\Harddisk0\Partition2
NumberOfLicensedUsers: 0
NumberOfProcesses: 157
NumberOfUsers: 2
OperatingSystemSKU: 49
Organization:
OSArchitecture: 64-bit
OSLanguage: 1033
OSProductSuite: 256
OSType: 18
OtherTypeDescription:
PAEEnabled:
PlusProductID:
PlusVersionNumber:
PortableOperatingSystem: False
Primary: True
ProductType: 1
RegisteredUser: developer
SerialNumber: 00332-00331-71784-AA054
ServicePackMajorVersion: 0
ServicePackMinorVersion: 0
SizeStoredInPagingFiles: 4637884
Status: OK
SuiteMask: 272
SystemDevice: \Device\HarddiskVolume2
SystemDirectory: C:\WINDOWS\system32
SystemDrive: C:
TotalSwapSpaceSize:
TotalVirtualMemorySize: 12910660
TotalVisibleMemorySize: 8272776
Version: 10.0.10586
WindowsDirectory: C:\WINDOWS
Then again that link isn't verbose enough, as Google tells me that OperatingSystemSKU
has more than 26 items, as I've found 49 or even 103.
Another route is with Environment.OSVersion
but I think it's even worse than what i'm looking at.
So either I build a table for some form of lookup, or I reverse lookup an existing internal library.
My current solution is to get the OS Version and cross-reference a list I made from https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions
Update: Instead of sending a string with the OS Name, to my API, for bandwidth concerns, I want to send a unique ID that I can reverse lookup to retrieve the OS from the ID.
I'm currently building this database dynamically, using the string value of the OS and then an ID every other time.
I would like a solution that can retrieve the Caption
field if I have some of the other fields of Win32_OperatingSystem
and assuming that both client and server side have the latest dlls/SDKs.
TIA