JO
184 4
Asked
Updated
Viewed
24.7k times

Any ideas on how I could post something to the Application section of the logs you see through eventvwr as "information" with a Batch File?

Maybe even through cscript and vbs?

  • 0
    Check out eventcreate.exe in windows\system32 — Alkatr0z
  • 0
    Thanks, Alkatr0z, that's exactly what I'm looking for. 😁 I might have to go with somthing using VBS & WScript.Shell though, eventcreate.exe looks like it's Windows XP Professional & higher. I can think of a handfull of people who will use this that are running XP Home at the moment. — joebert
add a comment
1

2 Answers

  • Votes
  • Oldest
  • Latest
Answered
Updated

For those who can use eventcreate to write to the event log as mentioned by Alkatr0z (I am currently using Windows 10), it would look like this:

EVENTCREATE /T ERROR /L APPLICATION /ID 100 /D "This is test information."

Running the eventcreate command from the Windows command line

Obviously, you don't have to run that directly from the CLI, you can put that in your batch file and run the command when needed. Here is the result in the application section of the logs in the Windows Event Viewer:

Log entry showing up in Windows Event Viewer

add a comment
0
JO
184 4
Answered
Updated

I found Wscript.Shell.LogEvent, which works on XP Home. Here's a glimpse of how this monster works:

eventcreate.vbs

'http://www.microsoft.com/technet/scriptcenter/guide/sas_log_akqy.mspx?mfr=true
'type, message[, remote computer]
Dim Args:			Set Args = Wscript.Arguments
Dim objShell:	Set objShell = Wscript.CreateObject("Wscript.Shell")

'objShell.LogEvent Args(0), Args(1), Args(2)
objShell.LogEvent Args(0), Args(1)

batch.bat

cscript "eventcreate.vbs" 4 "This is test information"
add a comment
0