Mega Code Archive

 
Categories / C# / Windows
 

Removes the registration for an event source if it has been registered

/* C# Programming Tips & Techniques by Charles Wright, Kris Jamsa Publisher: Osborne/McGraw-Hill (December 28, 2001) ISBN: 0072193794 */ // RemSrc.cs -- Removes the registration for an event source if //              it has been registered. // //              Compile this program with the following command line: //                  C:>csc RemSrc.cs using System; using System.Diagnostics; namespace nsEventLogs {     public class RemSrc     {         static public void Main (string [] args)         {             if (args.Length == 0)             {                 Console.WriteLine ("Please enter an event source to remove.");                 Console.WriteLine ("Usage: RemSrc [source]");                 return;             }             if (EventLog.SourceExists (args[0]))             {                 Console.WriteLine ("Deleting event log source " + args[0]);                 EventLog.DeleteEventSource (args[0]);             }         }     } }