Archive for January, 2012|Monthly archive page

Email alerts for completion errors with scheduled FreeFileSync jobs

Update(2014/04/24): You can find more on this topic at the following forum post: http://www.dostips.com/forum/viewtopic.php?f=3&t=5518&sid=26b92a8482829a3d758d3edd9bc09b96 – also in Andrea’s comments below.

Update (2012/03/07): So I really thought I had this working, but found I’d left off something quite important! On the findstr line there was a missing switch before the search string. I’ve now added it below.

Update (2012/01/16): I’ve added a few lines so the log file is zipped before it’s sent and then deleted afterwards. I use 7zip but you could use something else. See code below.

I’m a big fan of FreeFileSync and use it at work for a few back up processes. However, it doesn’t have any error reporting/email alerting built into it. This means I have to manually check logs for errors. Adding complexity (i.e. additional required user steps) to back up processes is a terrible idea, so automating this processes would be a lot better.

One of the recent versions of the application included a new feature where it would execute a command line upon completion of a synchronization. With a bit of Googling I came up with a batch file to use with it. You’ll need to download mailsend from here:

http://www.muquit.com/muquit/software/mailsend/mailsend.html

Create a file called emailalert.bat. Edit it and add the code below. Be careful with line breaks. There should be 9 lines in total. The lines begin with (ish): @echo; timeout; for; findstr; if; 7zip; mailsend; del); respectively.  You’ll need to change the email settings, log location and mailsend location in order to get it working as expected.

@echo off
timeout 30
for /f "delims=" %%x in ('dir "C:\Log Location" /od /b') do set recent=%%x
findstr /m /C:"completed with errors!" "C:\Log Location\%recent%"
if %errorlevel%==0 (
"C:\Program Files\7-Zip\7z.exe" a "C:\Log Location\%recent%.7z" "C:\Log Location\%recent%"
"C:\Mailsend Location\mailsend.exe" +bc +cc -smtp smtpaddress -t to@address -f from@address -user username -pass password -sub "FreeFileSync Backup: %time%, %date% - Completed with errors!" -attach "C:\Log Location\%recent%"
del "C:\Log Location\%recent%.7z"
)

Once you’ve created this and edited it. I would change the errorlevel value to “1” and run it (this will send the error message even if your last sync completed successfully  – I’m assuming it did!) so you can test all the settings work correctly. Might take a few attempts to get mailsend up and running.

Once it’s working correctly and you’re receiving the emails with the log attachments, change the errorlevel back. Then add the full filepath to the batch file to FreeFileSync in Synchronization Settings under ‘On completion’.

The ‘timeout’ is in the script because I think there’s a bit of a delay before the log file is finished being created once the bat file is executed. I’m sure you could get away with a shorter delay, but I’d rather have a longer delay and definitely receive the error alert email. This command works under Windows 7/Server 2008 but for earlier versions of Windows you’ll need to use a different command line. Try some of the suggestions here:

http://www.robvanderwoude.com/wait.php

Advertisements

System Event Notification Service not starting on boot

Failed to connect to a windows service

Windows could not connect to the System Event Notification Service service. This problem prevents limited users from logging on to the system. As an administrative user, you can review the System Event Log for details about why the service didn’t respond.

I’ve been having a problem with this ever since I started using Windows 7. Intermittently Windows will boot up very slowly and either make it to my login with full profile but display the above message, or will end up in a temporary login which I will have to log off of and log back into. I’ve tried reinstalling Windows 7 from scratch (twice) but this problem always comes back. It finally got so frustrating I thought I would spend several hours trying to fix it. Occasionally this problem would also coincide with the Audio service not starting, but lately that had happened less.

My first assumption was that it was an update or driver that was causing the problem. So, I wanted to install, patch, update drivers in a sequence and then check everything was fine in-between reboots. I reinstalled and the problem came back nearly immediately and I couldn’t tie it to one step in particularly. I did a bit of searching for possible solutions and it transpired I had a “Windows Audio Endpoint Builder” error message in my start up logs.

I don’t know what prompted me to do this, but I went into my BIOS and checked I had disabled the on-board audio (I have an external Firewire sound card).  This immediately fixed the problem for me. It could be that if you updated the drivers for the on-board audio the problem would go away, also, so worth trying that as well. For the record I have an Asus M2N-SLI Deluxe. These have on-board sound using an ADI 1988B chipset.