將事件項添加到日志文件中。
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() 函數(shù)的輸出。
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");