lastError Property

Log Parser

lastError Property

Returns -1 if the Execute or ExecuteBatch methods encountered errors, parse errors, or warnings; 0 otherwise.

Read-only property.

Script Syntax

value = objLogQuery.lastError;


Return Value

An integer value containing -1 if the Execute or ExecuteBatch methods encountered errors, parse errors, or warnings; 0 otherwise.


Examples

JScript example:

var oLogQuery = new ActiveXObject("MSUtil.LogQuery");

// Create query text
var strQuery = "SELECT TimeGenerated, EventID INTO C:\\output.csv FROM System";
strQuery +=    " WHERE SourceName = 'Application Popup'";

// Execute query
oLogQuery.ExecuteBatch( strQuery );

// Check if errors occurred
if( oLogQuery.lastError != 0 )
{
    WScript.Echo("Errors occurred!");
}
else
{
    WScript.Echo("Executed successfully!");
}

VBScript example:

Dim oLogQuery
Dim strQuery

Set oLogQuery = CreateObject("MSUtil.LogQuery")

' Create query text
strQuery = "SELECT TimeGenerated, EventID INTO C:\output.csv FROM System"
strQuery = strQuery & " WHERE SourceName = 'Application Popup'"

' Execute query
oLogQuery.ExecuteBatch strQuery

' Check if errors occurred
If oLogQuery.lastError <> 0 Then
    WScript.Echo "Errors occurred!"
Else
    WScript.Echo "Executed succesfully!"
End If


See also:

LogQuery Object
Log Parser COM API Overview
C# Example


© 2004 Microsoft Corporation. All rights reserved.