![]() |
|
![]() |
The "EventLogCustomView" Command |
This command can be used to programatically add custom event views to the Windows event viewer (EventVwr.msc / EventVwr.exe).
You may wish to create a filter for specific sources if you have used "EventLogSource".
You use the eventviewer to manually create or update your filters and then take a copy of the definitions it creates to deploy to as many workstations or servers that you wish:
The macro takes these parameters:
The file will be installed with this name but it doesn't effect the view within the event viewer as the contents contains the name and description of the "custom view".
You can supply a "Folder" if you follow this xml file naming convention (the "Folder" parameter if supplied overrides this):
If you wanted the filter in the menu structure "a\b\c" then you could provide a filename such as "[a, b, c] SomeFilter.xml" or "[a,b,c]SomeFilter.xml".
The "FilterName" can be used to override this name.
Use the Event Viewer to create the template definitions you want (using the "Create Custom View" action) and then navigate to the "%ALLUSERSPROFILE%\Microsoft\Event Viewer\Views" directory tree. It contains one xml file per filter. Look for the highest numbered file (View_1.xml) or at least the latest xml file (sort by date/time). Either way confirm contents with notepad etc. Copy this file (I rename it to match the customview name).
When write protected the user must use "Filter Custom View" to alter filtering (or create new view from it).
The install probably needs to be elevated to install these files.
You can also use any of the following predefined options:
#define? DEFAULT_EVENTLOG_PROTECTED Y ;;By default we protect files #define? DEFAULT_EVENTLOG_VITAL N ;;By default file is not important enought to FORCE an about *user allowed to ignore issues on these files) #define? EVENTLOG_FILTER_ROOT_DIR [CommonAppDataFolder]\Microsoft\Event Viewer\Views ;;You can add to this if you want your root to be a company name under this etc
EXAMPLES |
The following demonstrates some variations:
<$EventLogCustomView FilterXml="ALL WSH (last 30 days).xml"> ;--- The following both go into same menu location --- <$EventLogCustomView FilterXml="Some filter name1.xml" Folder="Product X\Sub Menu"> <$EventLogCustomView FilterXml="[Product X, Sub Menu] Some filter name2.xml">
This shows how to add all the available filter files (as long as you can supply a mask that only selects them):
#DefineRexx '' ;--- Get list of "[*.xml" files --- call Files4Mask "[*.xml", "CustomView" #DefineRexx #{ FOR FileNumber = 1 to CustomView.0 ;--- Process each of the files in turn --- <$EventLogCustomView FilterXml="<??CustomView.FileNumber>"> #}
![]() ![]() |
| ![]() ![]() |