I'm creating an ASP.NET application that will log some stuff to Windows EventLog. To do this an event source has to be created first. This requires administrative priviledges so I cannot do it in the ASP.NET app.
Is there an existing command-line application that is bundled with Windows that can create an event log source, or must I roll out my own?
Try PowerShell 2.0's EventLog cmdlets
Throwing this in for PowerShell 2.0 and upwards:
Run
New-EventLog
once to register the event source:Then use
Write-EventLog
to write to the log:Try "eventcreate.exe"
An example:
This will create a new event source named
MYEVENTSOURCE
underAPPLICATION
event log asINFORMATION
event type.I think this utility is included only from XP onwards.
Further reading
Windows IT Pro: JSI Tip 5487. Windows XP includes the EventCreate utility for creating custom events.
Type
eventcreate /?
in CMD promptMicrosoft TechNet: Windows Command-Line Reference: Eventcreate
SS64: Windows Command-Line Reference: Eventcreate