Jump to content

WshShell.LogEvent Equivalent?


Recommended Posts

I searched the forum here and found scant reference for this. Maybe I missed it though.

In any case, I am converting some VBS code I use to AutoIT v3 (not beta) and one thing I make heavy use of is WshShell.LogEvent. I could really use a widget to write events to the Windows EventLogs. I could use the Reskit utility called Logevent.exe but I would rather not.

If I missed something in the documentation I apologize in advance.

Thanks,

-Chris

Link to comment
Share on other sites

I searched the forum here and found scant reference for this. Maybe I missed it though.

In any case, I am converting some VBS code I use to AutoIT v3 (not beta) and one thing I make heavy use of is WshShell.LogEvent. I could really use a widget to write events to the Windows EventLogs. I could use the Reskit utility called Logevent.exe but I would rather not.

If I missed something in the documentation I apologize in advance.

Thanks,

-Chris

You need this U3Xtra.dll (search the forums)

and this:

Global $EVENTLOG_SUCCESS = 0x0000
Global $EVENTLOG_ERROR_TYPE = 0x0001
Global $EVENTLOG_WARNING_TYPE = 0x0002
Global $EVENTLOG_INFORMATION_TYPE = 0x0004
Global $EVENTLOG_AUDIT_SUCCESS = 0x0008
Global $EVENTLOG_AUDIT_FAILURE = 0x0010
;
$x = DLLCall("AdvApi32.dll","hwnd","RegisterEventSource","str","","str","Application")

DLLCall("AU3Xtra.dll", "int", "EventLogWrite","hwnd", $x[0],"short", $EVENTLOG_INFORMATION_TYPE,"long", 222,"str", "LOG THIS !!!")

$x = DLLCall("AdvApi32.dll","int","DeregisterEventSource","hwnd",$x[0])

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

You really should use beta. It's more stable than production.

Global Const $SUCCESS = 0
Global Const $ERROR =1
Global Const $WARNING =2     
Global Const $INFORMATION =4     
Global Const $AUDIT_SUCCESS =8     
Global Const $AUDIT_FAILURE =16     
 
 
$WshShell = ObjCreate("WScript.Shell")
if @error or $WshShell = 0 Then
    MsgBox(266288,"WshShell","Could not create object.")
    Exit
EndIf

$WshShell.LogEvent ($INFORMATION, "Script started.")
;
;do stuff.
;
$WshShell.LogEvent ($SUCCESS, "Script completed." )

$WshShell = 0
Exit
Edited by eltorro
Link to comment
Share on other sites

You really should use beta. It's more stable than production.

????

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

If you really want to convert the vbs code into autoit i believe you'll need the beta for ObjCreate

I could do that, but if I write it myself I would learn a lot more.

You really should use beta. It's more stable than production.

That's pretty unusual.

Thank you for the code snippets. I'm sure I can break it pretty well from there. :D

-Chris

Edited by AramisResearch
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...