将事件项添加到日志文件中。
object.LogEvent(intType, strMessage [,strTarget])
LogEvent 方法返回一个布尔值(如果事件记录成功,则返回 true,否则返回 false)。在 Windows NT/2000 中,事件记录在 Windows NT 事件日志中。在 Windows 9x/Me 中,事件记录在 WSH.log(位于 Windows 目录中)中。有六种事件类型。
| 类型 | 值 |
|---|---|
| 0 | SUCCESS |
| 1 | ERROR |
| 2 | WARNING |
| 4 | INFORMATION |
| 8 | AUDIT_SUCCESS |
| 16 | AUDIT_FAILURE |
下面的代码记录“成功”或“错误”,这取决于 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");