all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
1
Task/Write-to-Windows-event-log/0DESCRIPTION
Normal file
1
Task/Write-to-Windows-event-log/0DESCRIPTION
Normal file
|
|
@ -0,0 +1 @@
|
|||
Write script status to the Windows Event Log
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
INSTALL @lib$+"COMLIB"
|
||||
PROC_cominitlcid(1033)
|
||||
|
||||
WshShell% = FN_createobject("WScript.Shell")
|
||||
PROC_callmethod(WshShell%, "LogEvent(0, ""Test from BBC BASIC"")")
|
||||
|
||||
PROC_releaseobject(WshShell%)
|
||||
PROC_comexit
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
using System.Diagnostics;
|
||||
|
||||
namespace RC
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
string sSource = "Sample App";
|
||||
string sLog = "Application";
|
||||
string sEvent = "Hello from RC!";
|
||||
|
||||
if (!EventLog.SourceExists(sSource))
|
||||
EventLog.CreateEventSource(sSource, sLog);
|
||||
|
||||
EventLog.WriteEntry(sSource, sEvent);
|
||||
EventLog.WriteEntry(sSource, sEvent, EventLogEntryType.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
program WriteToEventLog;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
uses Windows;
|
||||
|
||||
procedure WriteLog(aMsg: string);
|
||||
var
|
||||
lHandle: THandle;
|
||||
lMessagePtr: Pointer;
|
||||
begin
|
||||
lMessagePtr := PChar(aMsg);
|
||||
lHandle := RegisterEventSource(nil, 'Logger');
|
||||
if lHandle > 0 then
|
||||
begin
|
||||
try
|
||||
ReportEvent(lHandle, 4 {Information}, 0, 0, nil, 1, 0, @lMessagePtr, nil);
|
||||
finally
|
||||
DeregisterEventSource(lHandle);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
WriteLog('Message to log.');
|
||||
end.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
: (call 'logger "This is a test")
|
||||
-> T
|
||||
|
||||
: (call 'logger "This" 'is "another" 'test)
|
||||
-> T
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
# Create Event Log object
|
||||
$EventLog=new-object System.Diagnostics.EventLog("Application")
|
||||
#Declare Event Source; must be 'registered' with Windows
|
||||
$EventLog.Source="Application" # It is possible to register a new source (see Note2)
|
||||
# Setup the Event Types; you don't have to use them all, but I'm including all the possibilities for reference
|
||||
$infoEvent=[System.Diagnostics.EventLogEntryType]::Information
|
||||
$errorEvent=[System.Diagnostics.EventLogEntryType]::Error
|
||||
$warningEvent=[System.Diagnostics.EventLogEntryType]::Warning
|
||||
$successAuditEvent=[System.Diagnostics.EventLogEntryType]::SuccessAudit
|
||||
$failureAuditEvent=[System.Diagnostics.EventLogEntryType]::FailureAudit
|
||||
|
||||
# Write the event in the format "Event test",EventType,EventID
|
||||
$EventLog.WriteEntry("My Test Event",$infoevent,70)
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
Procedure WriteToLog(Event_App$,EventMessage$,EvenetType,Computer$)
|
||||
|
||||
Protected wNumStrings.w, lpString=@EventMessage$, lReturnX, CMessageTyp, lparray
|
||||
Protected lprawdata=@EventMessage$, rawdata=Len(EventMessage$), Result
|
||||
Protected lLogAPIRetVal.l = RegisterEventSource_(Computer$, Event_App$)
|
||||
|
||||
If lLogAPIRetVal
|
||||
lReturnX = ReportEvent_(lLogAPIRetVal,EvenetType,0,CMessageTyp,0,wNumStrings,rawdata,lparray,lprawdata
|
||||
DeregisterEventSource_(lLogAPIRetVal)
|
||||
Result=#True
|
||||
EndIf
|
||||
|
||||
ProcedureReturn Result
|
||||
EndProcedure
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
import win32api
|
||||
import win32con
|
||||
import win32evtlog
|
||||
import win32security
|
||||
import win32evtlogutil
|
||||
|
||||
ph = win32api.GetCurrentProcess()
|
||||
th = win32security.OpenProcessToken(ph, win32con.TOKEN_READ)
|
||||
my_sid = win32security.GetTokenInformation(th, win32security.TokenUser)[0]
|
||||
|
||||
applicationName = "My Application"
|
||||
eventID = 1
|
||||
category = 5 # Shell
|
||||
myType = win32evtlog.EVENTLOG_WARNING_TYPE
|
||||
descr = ["A warning", "An even more dire warning"]
|
||||
data = "Application\0Data".encode("ascii")
|
||||
|
||||
win32evtlogutil.ReportEvent(applicationName, eventID, eventCategory=category,
|
||||
eventType=myType, strings=descr, data=data, sid=my_sid)
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
/*REXX program writes a "record" (event) to the (MS) Windows event log.*/
|
||||
|
||||
eCMD = 'EVENTCREATE'
|
||||
type = 'INFORMATION' /*one of: ERROR WARNING INFORMATION */
|
||||
id = 234 /*in range: 1 ───► 1000 (inclusive).*/
|
||||
logName = 'APPLICATION'
|
||||
source = 'REXX'
|
||||
desc = 'attempting to add an entry for Rosetta Code demonstration.'
|
||||
desc = '"' || desc '"' /*enclose DESCription in double quotes.*/
|
||||
|
||||
eCMD '/T' type "/ID" id '/L' logName "/SO" source '/D' desc
|
||||
|
||||
/*stick a fork in it honey, we're done.*/
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
require 'win32/eventlog'
|
||||
logger = Win32::EventLog.new
|
||||
logger.report_event(:event_type => Win32::EventLog::INFO, :data => "a test event log entry")
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
package require twapi
|
||||
|
||||
# This command handles everything; use “-type error” to write an error message
|
||||
twapi::eventlog_log "My Test Event" -type info
|
||||
Loading…
Add table
Add a link
Reference in a new issue