[python-win32] Windows LogParser COM interface
Ronnie Jones
7qrj45 at clayelectric.com
Mon Jun 6 14:52:46 CEST 2005
I am trying to access LogParser 2.2 through the COM interface provided
and I am having a bit of a problem. Here is what is going on: First up
is the VBScript version of the code then comes the Python version.
Set objLogParser = CreateObject("MSUtil.LogQuery") Set objInputFormat =
_
CreateObject("MSUtil.LogQuery.FileSystemInputFormat")
objInputFormat.recurse = 0
Set objOutputFormat = _
CreateObject("MSUtil.LogQuery.NativeOutputFormat")
objOutputFormat.rtp = -1
strQuery = "SELECT Name, Size FROM 'C:\Program Files\Log Parser 2.2\*.*'
ORDER BY Name ASC"
objLogParser.ExecuteBatch strQuery, objInputFormat, objOutputFormat
When I installed Log Parsers 2.2 on WinXP home edition SP1 version 2002
it went in c:\Program Files\Log Parser 2.2 and then I ran regsvr32
LogParser.dll from that directory. The error I get is :
Error executing query:Error while writing to file: The handle is
invalid.
NOW!! This occurs when I run the script from the command line just by
typing the script name and letting XP load cscript. However if I type:
cscript test.vbs from the command line it runs ok. Now what I am trying
to do is program this interface from ActiveState python 2.3 with
win32com extentions. Everything works fine but when I run the script I
get the same error I get when I type 'test.vbs' at the command line.
Python is my main language and I would really like to make it work. It
seems like there is some condition of having the script directly called
from 'cscript' for the COM interface to work. Does anyone know the
workings of the COM interface. I understand the API, but how are the
calls being made. Here is the python code for the same example:
>>> import win32com.client
>>> objLogParser = win32com.client.Dispatch("MSUtil.LogQuery")
>>> objOutput =
win32com.client.Dispatch("MSUtil.LogQuery.NativeOutputFormat")
>>> objOutput.rtp = -1
>>> objInput =
win32com.client.Dispatch("MSUtil.LogQuery.FileSystemInputFormat")
>>> objInput.recurse = 0
>>> myquery = "SELECT Name, Size FROM 'C:/lame/misc/*.*' ORDER BY Name
ASC"
>>> objLogParser.ExecuteBatch(myquery, objInput, objOutput)
Traceback (most recent call last):
File "", line 1, in ?
File
"C:\Python23\Lib\site-packages\win32com\gen_py\A7E75D86-41CD-4B6E-B4BD-C
C2ED34B3FB0x0x1x0.py", line 819, in ExecuteBatch
return self._oleobj_.InvokeTypes(2, LCID, 1, (11, 0), ((8, 1), (13, 49),
(13, 49)),szQuery, pObjectInputContext, pObjectOutputContext)
com_error: (-2147352567, 'Exception occurred.', (0, 'CLogQueryClass',
'Error executing query: Error while writing to file: The handle is
invalid. [The handle is invalid.]', None, 0, -2147024890), None)
Any ideas would be appreciated. I can run the select command at the
command line using LogParser.exe and all is well but not with COM.
Thank you,
Ronnie Jones
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20050606/5d84cc58/attachment.html
More information about the Python-win32
mailing list