It is currently May 29th, 2023, 10:38 pm

[FEATURE IDEA] Event Viewer Plugin

Report bugs with the Rainmeter application and suggest features.
User avatar
Yincognito
Rainmeter Sage
Posts: 5337
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

[FEATURE IDEA] Event Viewer Plugin

Post by Yincognito »

I recently read a post about monitoring the Event Viewer for various events - I even discovered an alternative way to do it - and I was wondering if the Rainmeter team or a plugin developer thought about making a plugin to monitor the Event Viewer log at standard (or not) update rates, similar to how other plugins / measures work.

This could have the potential of being useful in debugging various errors within the system, for example, since a skin based on such a plugin could provide a near immediate notification to the user as soon as such an error / event is happening, as opposed to only discovering the error much later without remembering exactly what happened or what led to it. As far as I could tell, there doesn't seem to be any counter in PerfMon.msc to provide such a thing (apart from the usual "how many stuff per session" kind of things), and coding it in C++/C# shouldn't be too difficult (I suppose), so why not?
Profiles: Rainmeter ProfileDeviantArt Profile ◆ Suites: MYiniMeter ◆ Skins: Earth
User avatar
nek
Posts: 91
Joined: November 3rd, 2019, 12:00 am

Re: [FEATURE IDEA] Event Viewer Plugin

Post by nek »

How about a trigger On an event of Task Scheduler? taskschd.msc

An example task for monitoring a event log:

Code: Select all

**Trigger**

       Trigger: On an event
           Log: Application
        Source: EventCreate
      Event ID: 100

**Action**

        Action: Start a program
Program/script: C:\Apps\misc\notifu.exe
 Add arguments: /t error /d 5000 /p "Title" /m "Message"
      Start in: C:\Apps\misc
Testing (command prompt - run as administrator):

Code: Select all

eventcreate.exe /t ERROR /id 100 /l application /d "Create event in application log"

📘 eventcreate.exe | https://learn.microsoft.com/windows-server/administration/windows-commands/eventcreate
> notifu.exe | https://github.com/ixe013/notifu
> Notifu is a tool that displays a yellow pop-up balloon in the system notification area
User avatar
Yincognito
Rainmeter Sage
Posts: 5337
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [FEATURE IDEA] Event Viewer Plugin

Post by Yincognito »

nek wrote: May 13th, 2023, 4:46 pm How about a trigger On an event of Task Scheduler? taskschd.msc

An example task for monitoring a event log:

Code: Select all

**Trigger**

       Trigger: On an event
           Log: Application
        Source: EventCreate
      Event ID: 100

**Action**

        Action: Start a program
Program/script: C:\Apps\misc\notifu.exe
 Add arguments: /t error /d 5000 /p "Title" /m "Message"
      Start in: C:\Apps\misc
Testing (command prompt - run as administrator):

Code: Select all

eventcreate.exe /t ERROR /id 100 /l application /d "Create event in application log"

📘 eventcreate.exe | https://learn.microsoft.com/windows-server/administration/windows-commands/eventcreate
> notifu.exe | https://github.com/ixe013/notifu
> Notifu is a tool that displays a yellow pop-up balloon in the system notification area
Thanks for answering, but if I'm not mistaken, this involves manually adding the task to the Task Sheduler and running another application (i.e. notifu), not to mention running things as an administrator. What I'm looking for is a way to monitor events in a Rainmeter skin, without any 3rd party application (as in not from Rainmeter or Windows), as the logged on user. I know I can add tasks to the Task Scheduler, but the idea was to integrate it with Rainmeter, in a way that is configurable as a skin.

That being said, I already can do this in PowerShell (both the testing and the monitoring) without having to run it as an administrator...

Test:

Code: Select all

Write-EventLog -LogName "Application" -Source "WSH" -EventID 0 -EntryType Information -Message "Event written to an event log using a script."
Monitor:

Code: Select all

While ($True) {Try {Get-WinEvent -FilterHashtable @{LogName='Application'; ProviderName='WSH'; ID='0'; StartTime=(Get-Date).AddMilliseconds(-1000)} -MaxEvents 1 -ErrorAction Stop} catch {}; Start-Sleep -Milliseconds 1000;}
...but while this works in PowerShell, the monitoring command doesn't seem to produce STDOUT results that can be captured by a RunCommand measure, because of the loop. Once I solve this, it will work, but it would have been nice to do this from a Rainmeter plugin, without having to trial and error script variants.

P.S. The CScript method I referrred to in the 2nd earlier link is way faster than the PS one and would be the preferred one, but it requires running it as an administrator and according to Brian is slightly unreliable for the future.
Profiles: Rainmeter ProfileDeviantArt Profile ◆ Suites: MYiniMeter ◆ Skins: Earth