Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion SharePointLogViewer/SPUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ public static SPVersion SPVersion
return SPVersion.SP2013;
}

// Check for SP2016
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\16.0\WSS");
if (key != null)
{
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\16.0");
return SPVersion.SP2016;
}

// Check for SP2019
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\17.0\WSS");
if (key != null)
{
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\17.0");
return SPVersion.SP2019;
}

}
catch (SecurityException) { }
return SPVersion.Unknown;
Expand Down Expand Up @@ -189,6 +205,10 @@ public static IEnumerable<string> GetServerNames()
farmType = Type.GetType("Microsoft.SharePoint.Administration.SPFarm, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
else if (SPUtility.SPVersion == SPVersion.SP2013)
farmType = Type.GetType("Microsoft.SharePoint.Administration.SPFarm, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
else if (SPUtility.SPVersion == SPVersion.SP2016)
farmType = Type.GetType("Microsoft.SharePoint.Administration.SPFarm, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
else if (SPUtility.SPVersion == SPVersion.SP2019)
farmType = Type.GetType("Microsoft.SharePoint.Administration.SPFarm, Microsoft.SharePoint, Version=17.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");


if (farmType != null)
Expand All @@ -213,13 +233,22 @@ static RegistryKey GetMOSSRegistryKey()
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Office Server\14.0");
else if (key == null)
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Office Server\15.0");
else if (key == null)
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Office Server\16.0");
else if (key == null)
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Office Server\17.0");

return key;
}

static RegistryKey GetWSSRegistryKey()
{
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0");
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\17.0");
if (key == null)
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\16.0");
else if (key == null)
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0");
else if (key == null)
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0");
else if (key == null)
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0");
Expand Down Expand Up @@ -260,6 +289,11 @@ private static string GetSPDiagnosticsLogLocation()
diagSvcType = Type.GetType("Microsoft.SharePoint.Administration.SPDiagnosticsService, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
else if (SPUtility.SPVersion == SPVersion.SP2013)
diagSvcType = Type.GetType("Microsoft.SharePoint.Administration.SPDiagnosticsService, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
else if (SPUtility.SPVersion == SPVersion.SP2016)
diagSvcType = Type.GetType("Microsoft.SharePoint.Administration.SPDiagnosticsService, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
else if (SPUtility.SPVersion == SPVersion.SP2019)
diagSvcType = Type.GetType("Microsoft.SharePoint.Administration.SPDiagnosticsService, Microsoft.SharePoint, Version=17.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");


if (diagSvcType != null)
{
Expand Down
4 changes: 3 additions & 1 deletion SharePointLogViewer/SPVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ enum SPVersion
Unknown,
SP2007,
SP2010,
SP2013
SP2013,
SP2016,
SP2019
}
}