Skip to content

Commit 5243300

Browse files
authored
Merge pull request #6045 from A9G-Data-Droid/FriendlyOSVersion
Decode Windows version in RD logs
2 parents 66c1360 + e5d4f55 commit 5243300

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Rubberduck.Core/App.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Application = System.Windows.Forms.Application;
1818
using Rubberduck.SettingsProvider;
1919
using System.IO.Abstractions;
20+
using Microsoft.Win32;
2021

2122
namespace Rubberduck
2223
{
@@ -231,11 +232,22 @@ public void LogRubberduckStart()
231232
{
232233
var version = _version.CurrentVersion;
233234
GlobalDiagnosticsContext.Set("RubberduckVersion", version.ToString());
235+
string osProductName = "";
236+
string osReleaseId = "";
237+
try
238+
{
239+
osProductName = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName", "").ToString();
240+
osReleaseId = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ReleaseId", "").ToString();
241+
}
242+
catch
243+
{
244+
Logger.Debug("Failure to read OS version from registry. Logged version will be incomplete.");
245+
}
234246

235247
var headers = new List<string>
236248
{
237249
$"\r\n\tRubberduck version {version} loading:",
238-
$"\tOperating System: {Environment.OSVersion.VersionString} {(Environment.Is64BitOperatingSystem ? "x64" : "x86")}"
250+
$"\tOperating System: {osProductName} {osReleaseId} {(Environment.Is64BitOperatingSystem ? "x64" : "x86")} ({Environment.OSVersion.VersionString})"
239251
};
240252
try
241253
{

0 commit comments

Comments
 (0)