Jump to content

Event log - Without WSH


desrtfx
 Share

Recommended Posts

Hello everybody!

Sorry, to introduce myself with a tricky question, but searching the forums didn't quite provide me the solution that I hoped to find.

I am quite familiar with creating scripts in AutoIT, but currently I am trying something that seems to be over my head.

I want to have a silent script that, upon completion, writes an entry to the windows event log.

I have seen the methods using the WSH - tried it - it works.

However, I would like to know whether there is a way to accomplish the same task without the WSH. The reason is that on several of my client machines where I run the scrip the WSH is disabled or very limited.

Any help on that matter would be greatly appreciated.

regards,

desrtfx

Link to comment
Share on other sites

Ok, this script has been copied from the forum:

$WshShell = ObjCreate("WScript.Shell")
if @error or $WshShell = 0 Then
    MsgBox(266288,"WshShell","Could not create object.")
    Exit
EndIf

$WshShell.LogEvent(4, "Hello World")

In the above script I use a switch "$silent" to indicate whether the program should display the message

boxes or not. I want to add a log entry instead of the message boxes when in silent mode.

Regards,

desrtfx

Edited by desrtfx
Link to comment
Share on other sites

@desrtfx, It looks like unless you have an eventlog message dll, you get an error in the event log viewer. See the following explanation:

http://www.codeproject.com/system/xeventlog.asp

EDIT: Why not use WSH? Issues with possible WSH corruption?

EDIT 2: Larry has included this functionality in his Au3Xtra dll. You can read more about it here.

Edited by this-is-me
Who else would I be?
Link to comment
Share on other sites

@Larry: Whew, that's some code here - my C skills are long since gone, but thanks anyway. I'll give the library a try.

@this-is-me: The complete code of my program is actually working perfectly well. - It's only a solution to update Symantec Antivirus Corporate behind a very restrictive and stupid firewall config on which I don't have any influence.

When I run the "Hello" example (WSH)it creates the event log entry without hassle. The only drawback I found is that it registers the event as "WSH" event and not from my program.

Have to rethink it.

Thanks for the help so far.

Regards,

desrtfx

Edit 1: I think I might resort to good old Text logfiles - is definitely easier. - Or I might add an event to Rainlendar - who knows :whistle:

Edited by desrtfx
Link to comment
Share on other sites

Larry's Library - Question

Could anybody please be so kind to give me a quick Au3 example on how to use the "EventLogWrite" function.

I am kinda lost here.

Say I want to make something like this:

func writeLogEntry($message, $state)
; $message is the message that should be recorded in the log
; $state is either success or fail - and that should set either $EVENTLOG_SUCCESS, or $EVENTLOG_ERROR_TYPE - for now.
.
;here's the critical code...???
.
EndFunc

I think if I can understand that trick, I can get going any further.

I really appreciate any help on that

many thanks

desrtfx

Link to comment
Share on other sites

@Larry:

Many, many, many thanks - that is just what I needed - ties my final knots! :whistle:;)

Now I can port my little script to production stage and will never miss an antivirus update!

Thanks again to everyone for the great help!

regards,

desrtfx

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...