INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Windows Scripting

How to copy the event log to a cursor by mgagnon
Posted: 31 Jan 04 (Edited 28 Jun 04)

The following was tested on VFP8.0, windows XP and Windows Scriting 5.6 installed:

CODE

Local x
x = 1
Create Cursor eventlogs (categorie N(10),;
 nomordi c(20),Code N(10),Message m,;
 nRecno N(10),Source c(50),dateheure T,Type c(20),usager c(20))
lcComputer = "."
loWMIService = Getobject("winmgmts:" ;
 + "{impersonationLevel=impersonate}!\\" + lcComputer + "\root\cimv2")
colRetrievedEvents = loWMIService.ExecQuery ;
 ("Select * from Win32_NTLogEvent")
For Each loEvent In colRetrievedEvents
 Wait Window Transform(x) Nowait
 Insert Into eventlogs (categorie,nomordi,Code,Message,nRecno,;
  source,dateheure,Type,usager) Values
(loEvent.Category,loEvent.ComputerName,;

loEvent.EventCode,Transform(loEvent.Message),loEvent.RecordNumber,loEvent.So
urceName,;
  WMIDateStringToDate(loEvent.TimeWritten),
loEvent.Type,Transform(loEvent.User))
 x = x + 1
Next
Function WMIDateStringToDate(dtmDate)
WMIDateStringToDate = Ctot(Substr(dtmDate, 5, 2) + "/" + ;
 Substr(dtmDate, 7, 2) + "/" + Left(dtmDate, 4) ;
 + " " + Substr(dtmDate, 9, 2) + ":" + ;
 Substr(dtmDate, 11, 2) + ":" + Substr(dtmDate, ;
 13, 2))
Return WMIDateStringToDate
Endfunc

Mike Gagnon

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close