Merge pull request #3 from ClementNotin/patch-2
Improve error message in ListDNSCache() when using Windows before 8/2012master
commit
4c20151af0
|
@ -4009,15 +4009,14 @@ namespace Seatbelt
|
|||
|
||||
public static void ListDNSCache()
|
||||
{
|
||||
Console.WriteLine("\r\n\r\n=== DNS Cache (via WMI) ===\r\n");
|
||||
|
||||
// lists the local DNS cache via WMI (MSFT_DNSClientCache class)
|
||||
|
||||
try
|
||||
{
|
||||
ManagementObjectSearcher wmiData = new ManagementObjectSearcher(@"root\standardcimv2", "SELECT * FROM MSFT_DNSClientCache");
|
||||
ManagementObjectCollection data = wmiData.Get();
|
||||
|
||||
Console.WriteLine("\r\n\r\n=== DNS Cache (via WMI) ===\r\n");
|
||||
|
||||
foreach (ManagementObject result in data)
|
||||
{
|
||||
Console.WriteLine(" Entry : {0}", result["Entry"]);
|
||||
|
@ -4025,6 +4024,10 @@ namespace Seatbelt
|
|||
Console.WriteLine(" Data : {0}\r\n", result["Data"]);
|
||||
}
|
||||
}
|
||||
catch (ManagementException ex) when (ex.ErrorCode == ManagementStatus.InvalidNamespace)
|
||||
{
|
||||
Console.WriteLine(" [X] 'MSFT_DNSClientCache' WMI class unavailable (minimum supported versions of Windows: 8/2012)", ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(" [X] Exception: {0}", ex.Message);
|
||||
|
|
Loading…
Reference in New Issue