Identify system operating system by identifier

I want to identify the OS, but not using String , since I want to map this as an identifier. Several ways to do this, so my question is:

Does anyone have a list of all the possible answers he gives?

 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 search the Caption field based on any other field?

Looking at https://msdn.microsoft.com/en-us/library/windows/desktop/aa394239(v=vs.85).aspx , it seems like there is not enough information to recreate Caption from all other properties.

Here is an example 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, this link is not detailed enough, since Google tells me that OperatingSystemSKU has more than 26 elements, since I found 49 or even 103.

Another route is with Environment.OSVersion , but I think it is even worse than what I am looking at.

Thus, either I create a table for some form of search, or reverse lookup an existing internal library.

My current solution is to get the OS version and cross-reference the list I made from https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions

Update: Instead of sending a string with the name of the OS to my API, for bandwidth problems, I want to send a unique identifier that I can cancel to extract the OS from the identifier.

I am currently creating this database dynamically using the string value of the OS and then the identifier each time.

I would like to get a solution that the Caption field can get if I have some other Win32_OperatingSystem fields and it is assumed that there are recent dll / SDKs on the client and server side.

TIA

+5
source share
1 answer

as i found 49 or even 103

Pumps up the problem pretty well. You are behind, now 121. The latest addition in version 10.0.10586 is Windows holographic, the one that you carry on your head.

The secret secret decoder is stored in the WinNT.h SDK header file, it contains PRODUCT_Xxxxx declarations. Your 49 == 0x31 == PRODUCT_PROFESSIONAL_N. Edition N refers to the EU and Switzerland, which is part of the settlement that forced Microsoft to no longer deploy Windows Media Player. It is important to get the latest version of the SDK in order to get an updated list. I looked at C: \ Program Files (x86) \ Windows Kits \ 10 \ Include \ 10.0.10586.0 \ um \ winnt.h, released about 3 months ago.

The number of versions of Windows hacked quickly, which is unlikely to decrease, although Microsoft promised that in the near future there will be no Windows version 11. Instrumental was a MinWin project , it violated the interdependencies between DLL files of the operating system. This greatly facilitated the creation of Windows assemblies that have a customized mix of parts. Server Core was the first known beneficiary of this project. Windows IoT (running on a microphone on a small scale) has had some noise lately.

A very obvious victim of this distribution is that version checking becomes completely useless. He no longer tells you what you can do in your code. There is also no practical way for Microsoft to continue to deploy gaskets that support older programs that are compatible with new releases of Windows. A massive commitment requiring the verification of tens of thousands of programs used in the normal mode is painful. Multiply this by the number of custom assemblies, such as holographic, and various publications that inspire politics and marketing (e.g. N, KN, E, V, S, A, EM), and you can imagine that this is not a problem that you want to decide for yourself.

Also pay attention to the behavior of the Environment.OSVersion environment, as well as the winapi functions such as GetWindowsVersionEx (), today's OS just lies with you and returns version 6.3. Windows 8.1 version number. Disabling this lie requires changing the target subsystem in the header of the EXE file..NET compilers used to install in 4.0, 6.0 if you are targeting a framework version 4.5 or higher (will not work on XP or Server2003). You must change it to 10.0. The backgrounder is here . The problem with the chicken and the egg is intentional.

Microsoft wants everyone to deal with this today, relying on feature-based checks in code. If it crashes because the OS does not have an auxiliary function, you should gracefully fail so that the user can understand that its publication is not enough. Very not what you are trying to do.

+18
source

Source: https://habr.com/ru/post/1243837/


All Articles