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.

Searching the contents of multiple 7-zip files

So around the time of the post I did about 7-zipping folders to individual zips I realised the built-in Windows search didn’t search within 7-zip files. Nor could I find any freeware or opensouce software that could do so, or at least that I was happy with.

7-zip can generate a file list of the contents of a 7-zip file. You can do this for multiple files spread across multiple folders using the following command:

"c:\Program Files\7-Zip\7z.exe" l * -r0 > filelist.txt

This way you can search within this text file for any files you may want to find within each 7-zip file. It’s not that elegant and has to be manually updated, but it does the job.

7-Zipping multiple folders to separate/individual zip/archive files

So I thought I would write this solution up as I had already made a batch file to do this then promptly deleted it (subsequently Recuva couldn’t ‘recuva’ it, as I’d been throwing a lot of data on and off my PC and thus I assume it was over-written).  The problem was I had several folders I wanted to zip into individual 7z archives.  7-zip lacks a ‘Add to “*.7z”‘ explorer context for multiple selected files or folders (even though it does include a ‘Extract to “*\”‘).  Nor does this option appear within the application itself or via the command-line.  I seem to recall this feature being available in the Explorer contexts for some ZIP program I once used (I think it was TUGzip), but I wanted to choose quite aggressive compression settings for the archives and I didn’t think this would be achievable except via the command-line.

So using a bit of Google skills I discovered the ‘for… in… do’ batch command.  Which is quite powerful and I’m sure will come in handy again now that I know about it.  For more information check out this guide: More Powerful Batch Files Part II – Iterating with “For”.  Coupled with the 7-zip manual I arrived at a batch file with this line in it:
for /d %%X in (*) do "c:\Program Files\7-Zip\7z.exe" a "%%X.7z" "%%X\" -mx=9 -ms=on -md=26 -mfb=256
So copy that into a batch file, copy it to the directory where you have folders you want to zip to individual archives and run it.  You might want to change (or just delete) the custom settings (e.g. the settings with -m at the end) as it set up to do some pretty heavy compression which does take quite a long time (but of course you can leave it running in the background without too much problem).

Resource Scheduling versus Conflicting Appointments

So, a user is setup on our Exchange 2003 server as resource.  I want to allow people to book the ‘user’ (i.e. room) as a resource, but I don’t want to allow them to book conflicting meeting.  So we have the option to select that within the room’s calendar setup (when setting up the room through Outlook 2003).  However, in order to allow users to book the room we have to give them at least ‘Author’ privileges.  Which means they can just go into the room’s calendar and book a meeting directly which can conflict.  If you only give the user ‘Reviewer’ privileges then they can’t book the room as a resource when creating a calendar appointment.

So the question I have is how do I avoid this situation?  I want to allow them to book the resource but not be able to create conflicting meetings directly in the calendar.

I’m sure I’m missing something…

Missing officeLR.cab file during Office 2007 install

Had a stupid problem last two days with the installation of Office 2007 SBE on a brand new Dell laptop.  For a reason I won’t bore you with I had to rebuild from scratch the Vista install and then reinstall Office 2007 using the OEM disk I received from Dell.  The install would fail just after inputting the serial number just as the install process began, with the error message:

“Setup cannot find Office.en-us\OfficeLR.cab.  Browse to a valid installation source, and then click OK.”

This file does exist on the CD but pointing the installation to the correct location doesn’t work.

There are various solutions dotted round the internet: Google “OfficeLR.cab” -torrent, but none of them seem to do the trick for me.  These include:

  1. Copying the office CD to a local folder and installing from there – simply didn’t work for me;
  2. Cleaning the CD as it could be damaged – didn’t work and nor did the 5 other identical disks I have;
  3. Copying the files in the cab to the same folder (after following solution 1) – once again, no joy.

So the easy solution, which I wish I’d thought of hours ago, is to download the trial version of the relevant Office suite and install that – in my case found here http://trial.trymicrosoftoffice.com/trialukireland/product.aspx?sku=3082936 but I’m sure with a bit of googling for your product and country you’ll find the correct trial version.  Well, it’s nearly the easy solution, because when I tried to install that package I got this message: “The installation of this package failed”.  A typically helpful error message there from Microsoft.  A quick google later (http://support.microsoft.com/kb/926946) and I try doing this:

Self-Extractor_filename.exe /extract:”C:\Office2007″

Which doesn’t work either.  However, it does work on my own PC running XP SP3.  Once the files were extracted I copied them to the laptop and ran the Setup.exe and the trial installed correctly.  Then I used the original serial number to convert the trial to the full version and it worked!  Interestingly, but probably unsurprisingly, the trial version looks very similar once unpacked to the original CD and it has the officeLR.cab file.  Luckily no error message with the trial.

I did try the originally installer CD on my desktop PC and it ran fine.  So I don’t understand why this error occurs on Vista – any ideas?  Perhaps something to do with the Windows Installer on Vista?  Anybody?

[1] I include the “-torrent” in the search as there seems to be lots of torrents for that particular file – no idea why.