Microsoft® Windows® Script Host
LogEvent Method
WSH Reference
Version 2

Applies To


Description
Logs an event in the Windows NT event log or WSH.log file.
Syntax
object.LogEvent(intType, strMessage [,strTarget])
Parameters
Part Description
object WshShell object.
intType Number representing the type of the event.
strMessage The text of the log entry.
strTarget Optional, Windows NT only. The name of the system where the event should be logged. Default is local system. Parameter is ignored on Windows 9x.
Remarks
LogEvent types may be one of the following:
Type Value
0 SUCCESS
1 ERROR
2 WARNING
4 INFORMATION
8 AUDIT_SUCCESS
16 AUDIT_FAILURE

On Windows NT: Logs an event in the Windows NT event log.

On Windows 9x: Logs an event in WSH.log, which will be in the users Windows directory. The WSH.log file will contain a time stamp, the event type, and the text of the log entry. 

Returns true if the event is successfully logged, otherwise returns false.
Example
The following example logs if a logon was successful or not:
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