Writing logs to Event viewer

Discuss new features and functions
Posts: 1
Joined: 20 Oct 2017

lex225

Wrote a batch file to write the logs to the Windows event viewer
Requirements:
--Free file sync must be set to save last 2 logs only
--Log location must be c:\logs

The logs are written to:
Log Name: Application
Source: FFSync
Event ID for error 1 - Warniing
Event ID for Success 2 - Informational

I created this so that I can pull the event monitors to my RMM platform and create tickets for errors

Free to use and improve by all
DEL "C:\logs\%computername%.txt"

cd\logs
DIR /S /B *error* >> "C:\logs\%computername%.txt"

SET file="C:\logs\%computername%.txt"
SET /a cnt=0
for /f %%a in ('type "%file%"^|find "" /v /c') do set /a cnt=%%a

IF %cnt% GTR 0 (
eventcreate /l APPLICATION /t WARNING /so FFSync /d "There are FreeFileSync errors" /id 1
)

IF %cnt% EQU 0 (
eventcreate /l APPLICATION /t INFORMATION /so FFSync /d "There are NO FreeFileSync errors" /id 2
)
FFsync.bat
(452 Bytes) Downloaded 146 times
Posts: 3
Joined: 16 Mar 2019

merovingio

Hi, i have a question.

I need to have an email after sync both when it is positive and when it is negative.

I tried to use this script but i have some problem.

If i run manually (double clic on the icon) the Batch Job of FreeFileSync, all is ok. But if i insert an automatic operation in the windows scheduler task, i received a Sync Error on the Event Viewer.

In the FreeFileSync log say: Sync OK

But in this file

c:\Users\Administrator\AppData\Roaming\FreeFileSync\Logs\%computername%.txt

i see this error

C:\Windows\system32\asferror.dll
C:\Windows\system32\ErrorDetails.dll
C:\Windows\system32\ErrorDetailsUpdate.dll
C:\Windows\system32\mferror.dll
C:\Windows\system32\SecurityAndMaintenance_Error.png
C:\Windows\system32\wmerror.dll
C:\Windows\system32\downlevel\api-ms-win-core-errorhandling-l1-1-0.dll
C:\Windows\system32\downlevel\api-ms-win-core-errorhandling-l1-1-1.dll
C:\Windows\system32\en-US\asferror.dll.mui
C:\Windows\system32\en-US\mferror.dll.mui
C:\Windows\system32\en-US\wmerror.dll.mui
C:\Windows\system32\migwiz\dlmanifests\Microsoft-Windows-IIS-HttpErrors-Deployment-DL.man
C:\Windows\system32\Tasks\Microsoft\Windows\ErrorDetails
C:\Windows\system32\Tasks\Microsoft\Windows\Windows Error Reporting
C:\Windows\system32\Tasks\Microsoft\Windows\ErrorDetails\EnableErrorDetailsUpdate
C:\Windows\system32\Tasks\Microsoft\Windows\ErrorDetails\ErrorDetailsUpdate
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\WindowsErrorReporting
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\WindowsErrorReporting\Microsoft.WindowsErrorReporting.PowerShell.dll
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\WindowsErrorReporting\WindowsErrorReporting.psd1
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\WindowsErrorReporting\WindowsErrorReporting.psm1
C:\Windows\system32\winevt\Logs\Microsoft-Windows-Kernel-WHEA%4Errors.evtx