Writing Events to Event Logs

Microsoft® Windows® 2000 Scripting Guide

Windows operating systems do not automatically record every event that takes place on a computer. Many events of interest, including logon scripts that failed, software that could not be installed, and drives that could not be mapped, are not recorded in the event logs and are therefore not automatically available to anyone analyzing the event logs.

If your scripts carry out activities that should be logged (either because they succeeded or because they failed), you can use the Windows Script Host (WSH) LogEvent method to record events in the Application event log.

note Note

  • WMI does not provide a method for writing events to the event logs.

Limitations of the LogEvent method

Before you begin using the LogEvent method in your scripts, it is important to understand the limitations inherent in this method:

  • The LogEvent method can record only events in the Application Log.

  • You cannot specify a unique event ID or a unique Event Source when using this method.

    Instead, all events are logged with an event ID that corresponds to the event type (for example, all successful events will have an event ID of 0) and the Event Source WSH. This makes it impossible to search for events derived from a particular script unless you include the script name as part of the Event Description.