AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Write to Windows event log?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
rkuechler



Joined: 31 Jan 2005
Posts: 6

PostPosted: Tue Apr 05, 2005 2:49 pm    Post subject: Write to Windows event log? Reply with quote

Question

Hi

Is there a possibility (or a command-line-tool) to write some information with an AHK-Script to the Windows event log?
Thanks for any suggestions!

Roman.
Back to top
View user's profile Send private message
blather



Joined: 12 Mar 2008
Posts: 3
Location: sfo

PostPosted: Mon Jun 16, 2008 4:47 pm    Post subject: using vbscript to write windows event log Reply with quote

Searching the forums, I did find a script to write the windows eventlog with a .dll call. It hadn't been converted into a function though and it didn't work for me so I switched to using vbscript ref:
http://www.autohotkey.com/forum/viewtopic.php?t=21674

Code:

#include ws4ahk.ahk

WriteWindowsEventLog(EventType,Message)
{
; ref: ms-help://MS.MSDNQTR.2006JAN.1033/script56/html/wsMthLogEvent.htm
; 0 SUCCESS
; 1 ERROR
; 2 WARNING
; 4 INFORMATION


    WS_Initialize()
   
   Code =
   (LTrim
   Set WshShell = CreateObject("WScript.Shell")
    WshShell.LogEvent %EventType%, "%Message%"
   )
   
   WS_Exec(Code)
   if ErrorLevel
      MsgBox,Writing to log failed: %ErrorLevel%
    WS_Uninitialize()
}



I'm not sure it's going to be wise to call WS_Uninitialize() in there if there are other parts of your application using ws4ahk.

This should be a pretty bullet-proof way of writing the event log that will work across windows platforms. Works for me on Vista anyway.
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group