8.1. Creating an Event
You want to write an event to an event log. This can be useful if you want to document certain actions you've performed on a server.
Using a command-line interface
The following command is available on Windows Server 2003:
> eventcreate /T
The following command writes an event to the Application event
log with event ID
999 and source
> eventcreate /T INFORMATION /ID 999 /L APPLICATION /SO SysAdmin /D "Restarting server after service pack install"
The logevent tool, which is available in the Windows 2000 Resource Kit, can also be used to create events:
> logevent -s
This example is equivalent to the eventcreate example where I created an event in the Application log:
> logevent -s I -e 999 -r SysAdmin "Restarting server after service pack install"
' This code creates an event in the Application event log. ' ------ SCRIPT CONFIGURATION ------ strServer = "\\
<ServerName>" ' e.g., fs01 strDescr = "
<EventDescr>" ' e.g., Restarting server after service pack install ' ------ END CONFIGURATION --------- Const EVENT_SUCCESS = 0 Const EVENT_ERROR = 1 Const EVENT_WARNING = 3 Const EVENT_INFO = 4 set objWSHShell = Wscript.CreateObject("Wscript.Shell") boolRC = objWSHShell.LogEvent(EVENT_INFO, strDescr, strServer) if boolRC = TRUE then WScript.Echo "Successfully created event." else WScript.Echo "Failed to create ...