How to create a custom event in Windows OS?

1.2k Views Asked by At

How can I create a custom event in Windows OS?

I must be able to create a custom event data containing various parameters.

It might be either using command prompt or PowerShell.

1

There are 1 best solutions below

5
On

You can always record entries into Application event log using call to one of overloads of method EventLog.WriteEvent. For example this one:

[System.Runtime.InteropServices.ComVisible(false)]
public void WriteEvent (System.Diagnostics.EventInstance instance, byte[] data, params object[] values);

Every .Net Class can be easily automated using Windows PowerShell.

Also there are exist special command for PowerShell - Write-EventLog:

Write-EventLog
     [-LogName] <String>
     [-Source] <String>
     [[-EntryType] <EventLogEntryType>]
     [-Category <Int16>]
     [-EventId] <Int32>
     [-Message] <String>
     [-RawData <Byte[]>]
     [-ComputerName <String>]
     [<CommonParameters>]

Mayby you will found it more useful.

In Python there are exist special logger class NTEventLogHandler which write event to Windows Event Log.