Get Windows Current and correct Information

Hi guys,
I´ve been working in a way to make the Robot run process properly according to the Environment it´s running with the intention to make it call the right path for a process that in windows 10 runs based on “c:\users\username\appdata\local” and in prior versions “C:\program files\application” with System.environment.OsVersion.Version (Major, Build) variations to get Windows Current Version and make it run the right choice but with no lucky on windows 8, 8.1 and 10 returns the same value.

Any suggestion?

thanks in advance.

Hello @Bern,
Please try System.Runtime.InteropServices.RuntimeInformation.OSDescription. This will return the OS description as a string. For eg, in Windows 10 it returns “Microsoft Windows 10.x.xxxxx”.

I am unable to test this in other Windows versions, so please try and let me know if this helped.

Hello @karavinds,
In prior versions this variable brings the CurrentVersion+CurrentBuild of running Os. It worked out since we have a more effective information to deal with.

Also i´ve achieved another way to make it getting ProductName from REGKEY using PowerShell.

Thank you so much !

Thanks for your response @Bern .

If you would like to use the same registry property and avoid dependency on PS, you could get the same result using Microsoft.Win32.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName", "").

2 Likes

Thank YOU @karavinds ! Perfect solution <3

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.