The easiest method of executing this sample is to paste the code inside the sample code of Opening networks and locating readers example, just after the number of users is displayed, but before the Logoff method is called.
// Assume that oReader holds a valid logged-on reader object. // Collect all events, this may take a while.... oReader.EventDatabase.CollectEvents(); // Copy all events to another object (only for readability) var oEvents = oReader.EventDatabase.Events; WScript.Echo("Number of collected events: " + oEvents.Count); // Start with the newest item in the collection var i = 0; var oEvent = oEvents.LastItem; while (oEvent && i < 10) { // Display a messagebox with the text WScript.Echo("Date: " + oEvent.Date + ", Event: " + oEvent.Description); // Get the previous item in the collection oEvent = oEvents.PreviousItem; // Simple counter to stop this loop if we displayed the last 10 events i++; }