none
Reading Windows Version numbers RRS feed

  • Question

  • Hi

    My computer is running :

    Windows 10 Pro

    Version 1903

    Build 18362.356

    When I try to read the version number whithin my program with

    'System.Environment.OSVersion.ToString()'

    I get : 'Microsoft NT 6.2.9200.0'

    When I try to read the version number whithin my program with

    'System.Environment.Version.ToString()'

    I get : '4.0.30319.42000'

    I dont think any of them are correct.

    Which System call will give me the correct responce ?

    Kind Regards

    Peter Tryk Harbo

    Sunday, September 29, 2019 2:40 PM

All replies

  • Windows has lied about version numbers for a while now unless your application is properly manifested. Environment.OSVersion Property says "The Environment.OSVersion property does not provide a reliable way to identify the exact operating system and its version. "

    I suggest you read Operating System Version for a fuller description of how Windows determines which version to report.

    Sunday, September 29, 2019 2:58 PM
  • You can get details from registry :

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

    or with WMI  (Win32_OperatingSystem)

    Sunday, September 29, 2019 2:59 PM
  • it would be easier to add the manifest that declares compatibility with Windows 10.
    Windows version check
    Sunday, September 29, 2019 3:15 PM
  • Hi Peter,

    As Castorix31 suggested, you could use registry to get windows version number.

    I write a simple code and you could refer to it.

         string releaseId = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ReleaseId", "").ToString();
         Console.WriteLine(releaseId);
            

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 30, 2019 2:02 AM
    Moderator