Adds an event entry to a log file.
object.LogEvent(intType, strMessage [,strTarget])
The LogEvent method returns a Boolean value (true if the event is logged successfully, otherwise false). In Windows NT/2000, events are logged in the Windows NT Event Log. In Windows 9x/Me, events are logged in WSH.log (located in the Windows directory). There are six event types.
| Type | Value |
|---|---|
| 0 | SUCCESS |
| 1 | ERROR |
| 2 | WARNING |
| 4 | INFORMATION |
| 8 | AUDIT_SUCCESS |
| 16 | AUDIT_FAILURE |
The following code logs SUCCESS or ERROR depending on the outcome of the function runLoginScript().
Set WshShell = WScript.CreateObject("WScript.Shell")
rc = runLoginScript() 'Returns true if logon succeeds.
if rc then
WshShell.LogEvent 0, "Logon Script Completed Successfully"
else
WshShell.LogEvent 1, "Logon Script failed"
end if
var WshShell = WScript.CreateObject("WScript.Shell");
var rc = runLoginScript();
if (rc)
WshShell.LogEvent(0, "Logon Script Completed Successfully");
else
WshShell.LogEvent(1, "Logon Script failed");