ExecuteBatch Method

Log Parser

ExecuteBatch Method

Executes a query and writes the output records to an output format.

Script Syntax

bResult = objLogQuery.ExecuteBatch(strQuery [, objInputFormat [, objOutputFormat ] ]);


Parameters

strQuery
A string containing the text of the SQL-Like query to be executed.
objInputFormat
Either an Input Format object or a Custom Input Format Plugin object.
If this parameter is not specified, or is null, Log Parser will attempt to select automatically an input format upon inspection of the <from-entity> in the FROM clause of the specified query.
objOutputFormat
An Output Format object.
If this parameter is not specified, or is null, Log Parser will attempt to select automatically an output format upon inspection of the <into-entity> in the INTO clause of the specified query.


Return Value

A boolean value. Returns TRUE if the query executed with parse errors or warnings; FALSE if the query executed without any parse error nor warning.


Remarks

  • If the query execution encounters errors, an exception is thrown containing the error message and code, and the query execution is aborted.
    In this case, the lastError property of the LogQuery object is set to -1, and the collection of strings returned by the errorMessages property contains the error message.
  • If the query execution encounters parse errors or warnings, the query executes successfully, and the method returns TRUE.
    In this case, the lastError property of the LogQuery object is set to -1, and the collection of strings returned by the errorMessages property contains the parse error messages and/or warning messages.


Examples

JScript example:

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

// Create Input Format object
var oEVTInputFormat = new ActiveXObject("MSUtil.LogQuery.EventLogInputFormat");
oEVTInputFormat.direction = "BW";

// Create Output Format object
var oCSVOutputFormat = new ActiveXObject("MSUtil.LogQuery.CSVOutputFormat");
oCSVOutputFormat.tabs = true;

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

// Execute query
oLogQuery.ExecuteBatch( strQuery, oEVTInputFormat, oCSVOutputFormat );

VBScript example:

Dim oLogQuery
Dim oEVTInputFormat
Dim oCSVOutputFormat 
Dim strQuery

Set oLogQuery = CreateObject("MSUtil.LogQuery")

' Create Input Format object
Set oEVTInputFormat = CreateObject("MSUtil.LogQuery.EventLogInputFormat")
oEVTInputFormat.direction = "BW"

' Create Output Format object
Set oCSVOutputFormat = CreateObject("MSUtil.LogQuery.CSVOutputFormat")
oCSVOutputFormat.tabs = TRUE

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

' Execute query
oLogQuery.ExecuteBatch strQuery, oEVTInputFormat, oCSVOutputFormat


See also:

LogQuery Object
Execute Method
Input Format Objects
Output Format Objects
Log Parser COM API Overview
C# Example


© 2004 Microsoft Corporation. All rights reserved.