| View previous topic :: View next topic |
| Author |
Message |
rkuechler
Joined: 31 Jan 2005 Posts: 6
|
Posted: Tue Apr 05, 2005 2:49 pm Post subject: Write to Windows event log? |
|
|
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 |
|
 |
blather
Joined: 12 Mar 2008 Posts: 3 Location: sfo
|
Posted: Mon Jun 16, 2008 4:47 pm Post subject: using vbscript to write windows event log |
|
|
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 |
|
 |
|