Tim Golden wrote: > Mårten Hedman wrote: >> Hello, >> >> I am trying to write a script for backing up and clearing event logs on >> our Windows 2003 servers, using Python 2.5 and Tim Golden's WMI module. >> While testing with the Application log on a local Windows XP machine I >> seem to get stuck on the parameters to WMI. >> >> The following code: >> >> import wmi >> c = wmi.WMI(privileges=["Backup"]) >> logfiles = c.ExecQuery("SELECT * FROM Win32_NTEventLogFile WHERE >> LogFileName='Application'") >> >> for lf in logfiles: >> lf.BackupEventLog("c:\\temp\\Applog.evt") >> >> gives the following error message: >> >> Traceback (most recent call last): >> File "<interactive input>", line 2, in <module> >> File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line >> 491, in __getattr__ >> raise pythoncom.com_error, details >> com_error: (-2147352567, 'Exception occurred.', (0, 'SWbemObjectEx', >> 'Invalid parameter ', None, 0, -2147217400), None) > > I doubt if the moniker's got anything to do with it. > You're just falling foul of the fact that I haven't > released the fix which allows positional args in > a WMI method call: you have to use named args. So... > > <dump> > >>> import wmi > >>> c = wmi.WMI () > >>> log = c.Win32_NTEventLogFile > >>> print log.BackupEventlog > <function BackupEventlog (ArchiveFileName) => (ReturnValue) | Needs: > SeSecurityPrivilege, SeBackupPrivilege> > >>> > > </dump> > > ... try: > > lf.BackupEventLog (ArchiveFileName="c:\\temp\\blah.blah")
Thank you for your quick answer. Unfortunately I get the same error message. BTW, is WMI case sensitive regarding method names? If I run your example with 'print log.BackupEventLog', I get the error: <dump> >>> c=wmi.WMI() >>> log=c.Win32_NTEventLogFile >>> print log.BackupEventLog Traceback (most recent call last): File "<interactive input>", line 1, in <module> File "C:\Python25\lib\site-packages\wmi.py", line 474, in __getattr__ handle_com_error (error_info) File "C:\Python25\lib\site-packages\wmi.py", line 188, in handle_com_error raise x_wmi, "\n".join (exception_string) x_wmi: -0x7ffdfff7 - Exception occurred. Error in: SWbemObjectEx -0x7ffbefd1 - Invalid method Parameter(s) >>> </dump> Both 'lf.BackupEventLog (ArchiveFileName="c:\\temp\\blah.blah")' and 'lf.BackupEventlog (...)' returns the same error though Mårten Hedman _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32