private static void InitializeLogging() { string datecode = DateTime.Now.ToString("yyyyMMddHHmmss"); string file = string.Format("{0}.log", datecode); string path = Path.Combine(Program.WorkingFolder, @"logs\console\"); Directory.CreateDirectory(path); m_Logger = new FileLogger(file, path, enabled: LoggingRequested); Console.SetOut(m_MultiConOut = new MultiTextWriter(Console.Out, m_Logger)); }
static void Main(string[] args) { MultiTextWriter m_MultiConOut; Console.SetOut(m_MultiConOut = new MultiTextWriter(Console.Out, new FileLogger(outFile, append: false))); Console.WriteLine("OS Version {0} : {1}", System.Environment.OSVersion, WindowsNameServicesManager.GetWindowsVersion()); using (m_MultiConOut) { try { var wnms = new WindowsNameServicesManager(); var moc = WindowsNameServicesManager.GetNetworkConfigs(); foreach (ManagementObject mo in moc) { if ((bool)mo["IPEnabled"]) { Console.WriteLine(); Console.WriteLine(mo["Description"]); Console.WriteLine("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"); WindowsNameServicesManager.DumpInterfaceProps(mo); } } } catch (Exception ex) { Console.WriteLine(ex); } } Console.WriteLine("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"); Console.WriteLine("\n\nRegistry Info:"); WriteRegistryInterfaces(); System.Diagnostics.Process.Start("notepad.exe", outFile); }