Send email notification

Discuss new features and functions
User avatar
Site Admin
Posts: 7505
Joined: 9 Dec 2007

Zenju

A user sent me a script which may be useful for admins who want to run FreeFileSync and send a status report via email:

>I needed email notification containing log warnings and errors, so I wrote the attached VBS. It is probably not bug-free as I could test it only in my environment, but you are welcome to it. If it's something you would like to distribute to add value to your product, fell free to do so.
Again, thank you.
Lane Beneke
Attachments
FreeFileSync.vbs
(10.99 KiB) Downloaded 146876 times
Posts: 10
Joined: 17 Sep 2013

nodough

Hi All,

I've updated this script several times and thought it might be a good idea to upload the updated version.

Enjoy,
NoDough

Edit: Attachment removed in favor of newer version below.
Posts: 16
Joined: 13 Apr 2014

eahm

Hi, thank you for this. Few questions:

1) Do I have to put this file on "On completion:"? Just exactly like a .bat file?

2) Do I have to create multiple copies based on how many profiles I have? With different names?

3) How can I use it with the Gmail SMTP (SSL, Auth etc.)?

Thank again.
Posts: 10
Joined: 17 Sep 2013

nodough

Hello All,

Posting yet another update to the script. The most obvious change is I've added duration to the report.

eahm, I'll attempt to answer your questions.

1) The script will execute FreeFileSync.exe and wait for it to terminate. How it terminates is up to you, but the script will not continue until it does.

2) I like to divide my ffs_batch files up according to their task. But there's no reason you couldn't dump all your tasks into a single ffs_batch file.

3) Good question. I have no idea. But this site appears to guide you through it.

Enjoy!

Edit: Removed file attachment in favor of newer version below.
Posts: 1
Joined: 10 Nov 2014

berettatim

If for someone could help....
You could update the script to send email with more paramenters of authentication, I found this:
Const SMTPServer = "yourserver.yourdomain.com"
Const SMTPAuth = 1
Const SMTPPort = 25
Const SMTPUsername = "your.smtp.username"
Const SMTPPassword = "your.smtp.password"


oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = SMTPAuth
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPPort
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'SendUsingPort
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = SMTPUsername
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = SMTPPassword

Dim ArgArray(10,1)


ArgArray(6,0) = "SMTPServer"
ArgArray(6,1) = "oMsg.Configuration.Fields.Item(""http://schemas.microsoft.com/cdo/configuration/smtpserver"")"
ArgArray(7,0) = "SMTPAuth"
ArgArray(7,1) = "oMsg.Configuration.Fields.Item(""http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"")"
ArgArray(8,0) = "SMTPPort"
ArgArray(8,1) = "oMsg.Configuration.Fields.Item(""http://schemas.microsoft.com/cdo/configuration/smtpserverport"")"
ArgArray(9,0) = "SMTPUsername"
ArgArray(9,1) = "oMsg.Configuration.Fields.Item(""http://schemas.microsoft.com/cdo/configuration/sendusername"")"
ArgArray(10,0) = "SMTPPassword"
ArgArray(10,1) = "oMsg.Configuration.Fields.Item(""http://schemas.microsoft.com/cdo/configuration/sendpassword"")"
Posts: 2
Joined: 14 Nov 2015

teymur-bagirov

we use blat (command line smtp sender)
the next line in bat file after FFS is blat, which sends log.
that's it
Posts: 10
Joined: 17 Sep 2013

nodough

I've updated the script and attached it to this message. Updates include...

Added the fields for SMTP authentication.
Modified the Email send process to retry on failure.
Fixed bug finding log files.
Fixed bug calculating elapsed time.
Added server name and batch name to body of report.

NoDough

P.S.: Two users have inquired how to send the entire log file. This script is not designed to send the entire log file. The purpose of this script is to send only the errors and warnings when things go wrong.
Attachments
FreeFileSync.vbs
(20.3 KiB) Downloaded 146738 times
Posts: 11
Joined: 31 Mar 2016

FileSyncExpert

Thanks for sharing this. I worked on an similar Project with autohotkey. Its a beta Version.
When its done, i will share this to... I hope that it does not take longer than 2 - 3 Weeks...
Posts: 2
Joined: 13 Apr 2016

hughc

great script!

I modified it slightly to work with gmail as the SMTP provider, as SSL is required; adding an SSL param was not difficult, but I did not bother to expose it as a command line argument (for my end use) just a configuration constant:
Const SMTPSsl = 1
...
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = SMTPSsl
Hope that might help anyone making use.

As an aside, if you set up a dummy gmail account just for the purposes of sending the mail, you will need to enable the 'Less Secure Apps setting in order that mail be sent.

Image
cheers,
Hugh
Posts: 1
Joined: 9 Jun 2016

JonBenavides

it is possible to attach the last log file in email?
Posts: 7
Joined: 29 Apr 2016

timberval

Is it possible to insert in the subject the tag [Warning] or [Error] if the exiterror code is it?
Pls anyone could help?
Thank you.
Posts: 23
Joined: 9 Aug 2016

serendipityguy

it is possible to attach the last log file in email?JonBenavides
I guess that some of the log files are too large for email depending on the size of your backup disk.
Posts: 23
Joined: 9 Aug 2016

serendipityguy

A user sent me a script which may be useful for admins who want to run FreeFileSync and send a status report via email:
Lane BenekeZenju
Could this be added into the next build as a feature request? Thanks for sharing Lane.
Posts: 68
Joined: 13 Aug 2018

TheExpert

Hi all,

because of a change in the FFS batch files regarding the tags for log folder you have to replace the search string in the VBS script to find the log folder. If you don't change it you get mail notifications with the following line at the end of the mail "No log file is configured for this batch.".

Instead of the code "If InStr( sLine, "LogfileFolder" ) Then 'FIND LINE CONTAINING LOG FILE FOLDER"
you have to set "If InStr( sLine, "LogFolder" ) Then 'FIND LINE CONTAINING LOG FILE FOLDER".

Update 23 Aug 2018: There were some errors with the log file handling and with the search strings for errors or warnings which I have fixed now. You can choose between German and English error / warning search strings in the section for configuring the script settings. If there are errors or warnings in the log file the lines with the errors or warnings are now added to the notification mail as it was originally designed by Lane Beneke.

Update 08 Sep 2018: I found a new bug in the VBS script. Sometimes the script checked the wrong log file. This is possible if there is more than one job running at the same time. So I've uploaded a new version of the script with the bugfix.

Update 22 Oct 2018: There's now an option to define the path to another GlobalSettings.xml or similar named file.

Update 19 Nov 2018: Because of an error when there's no GlobalSettings.xml or similar named file defined I added a check for 'ConstGlobalSettingsFile': If it isn‘t defined the call procedure of FreeFileSync will be changed. And thanks to @timberetta I added the option for a SSL secured SMTP connection. I don't have the possibility to test the SSL encryption for the SMTP connection. Maybe someone else can test it and give feedback if this is working?

Update 26 Feb 2019: There was an error with parsing the command line when setting a GlobalSettings.xml or similar named file as parameter. Added the description of the new command line parameters 'SMTPSsl' and 'GlobalSettingsFile' to the usage manual at the beginning of the script.

Update 05 Mai 2020: Corrected an error with retrieving the log file under some circumstances.

Update 14 Feb 2021: Corrected an error with the error handling when sending mails.

Update 31 Aug 2021: Added constants 'IncludeServerNameInSubject' and 'IncludeSyncResultInSubject' to allow users to specify what to include in email subject.

You'll find the modified script in the attachment.

Kind Regards

TheExpert
Attachments
FreeFileSync.vbs
(24.87 KiB) Downloaded 145371 times
User avatar
Site Admin
Posts: 7505
Joined: 9 Dec 2007

Zenju

What about using FreeFileSync's "On completion" to send the email and evaluating "%logfile_path%"?
Posts: 68
Joined: 13 Aug 2018

TheExpert

Hi Zenju,

I asked for the usage of this new variable, but I didn't get information about this, see viewtopic.php?t=5590.

Can FreeFileSync now send mail notifications, too? For about more than a year this feature wasn't available. So I have to use the VBS script to get mail notifications.

Kind Regards

TheExpert
Posts: 1
Joined: 25 Oct 2018

Rechotech

@The Expert

I have been unable to get the most current script tor run i get an error message

Cannot find file"".

followed by windows script host message

C:\backup_scripts\FreeFileSync.vbs
line 469
Char 4
Error Invalid procedure coll or argument 'Mid'
code 800A0005

Any ideas.
Posts: 68
Joined: 13 Aug 2018

TheExpert

@The Expert

I have been unable to get the most current script tor run i get an error message

Cannot find file"".

followed by windows script host message

C:\backup_scripts\FreeFileSync.vbs
line 469
Char 4
Error Invalid procedure coll or argument 'Mid'
code 800A0005

Any ideas. Rechotech, 25 Oct 2018, 15:36
The issue with the line and char information in the error message is that these don't correspond to the lines and chars in the script. So it's not very easy to find the error.

Have you defined the path to the log files of your sync / backup jobs at the beginning of the script? Have you saved the job files with the option to save the log file to the same location as defined in the script? The script doesn't search for the file LastSync.log. It searches for log files named like the job with the suffix of the timestamp. And if there are more than one files it looks for the timestamp of the file.

Maybe it will help you to set the option DoDebug = True at the beginning of the script. This will show you a lot of windows with the variables set by the script during the run.
Posts: 19
Joined: 8 Nov 2018

sagitario

Hi,
I have the same error.
After some tests I find out the problem.
"Cannot find file "".

This is regarding the GlobalSettings. I put the default full path and the error message disappear. For some reason leaving blank don't work.
Const GlobalSettingsFile = "%appdata%\FreeFileSync\GlobalSettings.xml"
The second error Is regarding the log file. For some reason it can't find/read the log file. In the "Const BatchFile = " I put the full path to file instead the batchfile name only. Changing this and the error disappear and the script work like a charm.

Regards,

PS: The "log file search strings" need to be change to the current language that is use.
Posts: 68
Joined: 13 Aug 2018

TheExpert

OK, I will insert a check for ConstGlobalSettingsFile: If it isn‘t defined the call procedure of FreeFileSync has to be changed.

You can define the batch file as command line parameter. So there‘s no need to set the ConstBatchFile in the script. With the command line parameter you are able to use different batch files for your synchronisation jobs - if needed.
Posts: 19
Joined: 8 Nov 2018

sagitario

Define the batch file as command line parameter so there‘s no need to set the ConstBatchFile in the script is a good idea. Can you put a example how to execute the command?

By the way, if you are changing the script, can you add the SSL/TLS authentication?

Thank you for good job with this script.
Posts: 68
Joined: 13 Aug 2018

TheExpert

Thank you.

Please have look at the first lines of the script, where Lars Beneke as originator of this script described the usage:

' Usage: cscript.exe FreeFileSync.vbs <hideconsole true|false>
' <exefile d:\path\to\freefilesync.exe>
' <batchfile d:\path\to\batch.ffs_batch>
' <msgsubject "Message Subject for BatchName">
' <msgto recipient@somedomain.tld>
' <msgfrom sender@somedomain.tld>
' <smtpserver smtp.somedomain.tld | n.n.n.n>
' <smtpport nn>
' <smtpauth 0|1|2>
' <smtpusername "user@mailserver">
' <smtppassword "user's password">
'
' Notes: 1) Parameter/Value pairs can be specified at the
' command line, or changed in code below. Command
' line values override coded values.
' 2) If the word "BatchName" (case sensitive) is in the
' subject line, it will be replaced by the name of
' the batch file less path and extension.

Sorry, I'm not able to implement the SSL/TLS authentication because I don't have enough experience with Visual Basic Script to do this. Do you need this feature for the authentication with the mail server? Feel free to add this on your own or maybe there's someone else in this community who can help?
Posts: 19
Joined: 8 Nov 2018

sagitario

Yeh... stupid question I know. I already read that but never put it working well... it return all the time a script error regarding the reading log file. But I understand now that the problem is regarding the batchfile path. Putting the command batch script in a different folder where the vbscript is, need to put de full path to BatchFile and doing this the reading log error came across.

I'm just curious, I do not know this type of programming very well.

For now I sending through a old mailserver that still don't ask for SSL encryption, but is a question of time so that all mailservers only accept secure connections.

Regards,
Posts: 7
Joined: 29 Apr 2016

timberval


Sorry, I'm not able to implement the SSL/TLS authentication because I don't have enough experience with Visual Basic Script to do this. Do you need this feature for the authentication with the mail server? Feel free to add this on your own or maybe there's someone else in this community who can help? TheExpert, 09 Nov 2018, 14:17

This is the line to add/modify to implement SSL authentication (TLS is not possible in cdo):
(modify in date 10/11/18 because I left one row for mistake the following code is corrected)
'  SMTPAuth 0=off, 1=clear text, 2=NTLM.  IF YOU SET THIS
'  TO 1, THEN YOU MUST ALSO SET THE SMTPUSERNAME AND
'  SMTPPASSWORD FIELDS.
'  Use SSL for the connection (False or True)
Const SMTPAuth = 0
Const SMTPPort = 25
Const SMTPUsername = "your.smtp.username"
Const SMTPPassword = "your.smtp.password"
Const SMTPssl = False
'  THE SCRIPT WILL ATTEMPT TO SEND THE MESSAGE MaxEmailSendAttempts
'  TIMES BEFORE GIVING UP.  IF THE MESSAGE FAILS TO SEND, THE
'  SCRIPT WILL SET THE DOS ERRORLEVEL TO 1 UPON EXIT.
Const MaxEmailSendAttempts = 10
Const SleepSecondsBeforeRetryingEmailSend = 301
'  DoDebug CAUSES DIAGNOSTIC OUTPUT TO BE WRITTEN TO THE
'  CONSOLE.  NOTE THAT WSCRIPT.EXE USES DIALOG BOXES FOR
'  OUTPUT. SO USE CSCRIPT.EXE WHEN DODEBUG IS TRUE.
Const DoDebug = False
'  IF DODEBUG IS TRUE, AND THE SHELL IS EXECUTED FROM A SCHEDULE
'  OR SOME OTHER PROCESS, THEN THE VALUE BELOW WILL DELAY CLOSING
'  OF THE WINDOW SO YOU CAN EXAMINE THE DEBUG OUTPUT.
Const SleepSecondsBeforeClosingShell = 15
Const IncludeErrorsInReport = True
Const IncludeWarningsInReport = True
Const IncludeRuntimeStringInReport = True
Const IncludeRuntimeNumbersInReport = False
Const IncludeServerNameInReport = True
'  LOG FILE SEARCH STRINGS, LANGUAGE BASED
'  PLEASE SELECT THE CORRESPONDING STRINGS
'  GERMAN
'Const sLogFileError = "]  Fehler:"
'Const sLogFileWarning = "]  Warnung:"
'Const sLogFileSeriousError = "]  Schwerer Fehler:"
'  ENGLISH
Const sLogFileError = "]  Error:"
Const sLogFileWarning = "]  Warning:"
Const sLogFileSeriousError = "]  Serious Error:"
'--------------------------------------------------------------

'--------------------------------------------------------------
' CHANGE NOTHING FROM THIS POINT FORWARD
Dim bHideConsole, sExeFile, sBatchFile, sGlobalSettingsFile, dtExecutionTime, dtCompletionTime
Dim oMsg, fso, sLogFile, Args, i, j, ArgTemp, ArgLen, ArgFound, ArgErrors
Set oMsg = CreateObject("CDO.Message")
Set fso = CreateObject("Scripting.FileSystemObject")

bHideConsole = HideConsole
sExeFile = ExeFile
sBatchFile = BatchFile
sGlobalSettingsFile = GlobalSettingsFile
oMsg.Subject = MsgSubject
oMsg.From = MsgFrom
oMsg.To = MsgTo
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = SMTPAuth
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPPort
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'SendUsingPort
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = SMTPUsername
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = SMTPPassword
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = SMTPssl
Const sDashedLine = "--------------------------------------------------------------"
Const sErrLogNotFound = "Unable to locate Log file for processing."
Const sErrLogNotCfgrd = "No log file is configured for this batch."
' THESE VALUES MATCH THE EXIT CODES FOR THE FreeFileSync.exe PROGRAM
Dim ExitCodeArray(3)
ExitCodeArray(0) = "Synchronization completed successfully"
ExitCodeArray(1) = "Synchronization completed with warnings"
ExitCodeArray(2) = "Synchronization completed with errors"
ExitCodeArray(3) = "Synchronization was aborted"

' PARSE THE COMMAND LINE
Dim ArgArray(11,1)
ArgArray(0,0) = "HideConsole"
ArgArray(0,1) = "bHideConsole"
ArgArray(1,0) = "ExeFile"
ArgArray(1,1) = "sExeFile"
ArgArray(2,0) = "BatchFile"
ArgArray(2,1) = "sBatchFile"
ArgArray(3,0) = "MsgSubject"
ArgArray(3,1) = "oMsg.Subject"
ArgArray(4,0) = "MsgFrom"
ArgArray(4,1) = "oMsg.From"
ArgArray(5,0) = "MsgTo"
ArgArray(5,1) = "oMsg.To"
ArgArray(6,0) = "SMTPServer"
ArgArray(6,1) = "oMsg.Configuration.Fields.Item(""http://schemas.microsoft.com/cdo/configuration/smtpserver"")"
ArgArray(7,0) = "SMTPAuth"
ArgArray(7,1) = "oMsg.Configuration.Fields.Item(""http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"")"
ArgArray(8,0) = "SMTPPort"
ArgArray(8,1) = "oMsg.Configuration.Fields.Item(""http://schemas.microsoft.com/cdo/configuration/smtpserverport"")"
ArgArray(9,0) = "SMTPUsername"
ArgArray(9,1) = "oMsg.Configuration.Fields.Item(""http://schemas.microsoft.com/cdo/configuration/sendusername"")"
ArgArray(10,0) = "SMTPPassword"
ArgArray(10,1) = "oMsg.Configuration.Fields.Item(""http://schemas.microsoft.com/cdo/configuration/sendpassword"")"
ArgArray(11,0) = "SMTPssl"
ArgArray(11,1) = "oMsg.Configuration.Fields.Item(""http://schemas.microsoft.com/cdo/configuration/smtpusessl"")"
Posts: 68
Joined: 13 Aug 2018

TheExpert

@sagitario: Did you have a chance to test the SSL connection to your mail server after adding the lines timbretta added in his post above? Is it working? I hope I will have the time to build a new script at this weekend and will then add the SSL feature to the new script version.
Posts: 10
Joined: 15 Nov 2018

Squalo

Hi,
I have the same error.
After some tests I find out the problem.
"Cannot find file "".

This is regarding the GlobalSettings. I put the default full path and the error message disappear. For some reason leaving blank don't work.
Const GlobalSettingsFile = "%appdata%\FreeFileSync\GlobalSettings.xml"
The second error Is regarding the log file. For some reason it can't find/read the log file. In the "Const BatchFile = " I put the full path to file instead the batchfile name only. Changing this and the error disappear and the script work like a charm.

Regards,

PS: The "log file search strings" need to be change to the current language that is use. sagitario, 08 Nov 2018, 19:11
I have the same errors!
I solved the first error as sagitario said: I put the default full path and the error message disappear
But i can't solve the second error (i tried to put the full path of batchfile in Const BatchFile in vain)...
The script return this error:
line 465
Char 4
Error Invalid procedure coll or argument 'Mid'
code 800A0005
Posts: 19
Joined: 8 Nov 2018

sagitario

@sagitario: Did you have a chance to test the SSL connection to your mail server after adding the lines timbretta added in his post above? Is it working? I hope I will have the time to build a new script at this weekend and will then add the SSL feature to the new script version. TheExpert, 14 Nov 2018, 09:05
Sorry, but not. I already put the code in my script but didn't have free time to test it.

I ended up losing a lot more time trying to get the script work. My problem is that, for the sake of organization, I have the batch file in a folder outside where I have the FFS settings and vbscript .... So adding a command in the batch script return a error... I ended up doing 2 batch files. one in an external folder where I control what I want or not to sync and anothers in the various folders where I have the various scripts. So far it has been working fine, with the exception of a single problem which is the fact that I have FFS in Portuguese language (perceive by my posts in bad English that it is not my native language) and the log files are in UDF-8 and the script can not read the special characters in that format....
Posts: 19
Joined: 8 Nov 2018

sagitario

Hi,
I have the same error.
After some tests I find out the problem.
"Cannot find file "".

This is regarding the GlobalSettings. I put the default full path and the error message disappear. For some reason leaving blank don't work.
Const GlobalSettingsFile = "%appdata%\FreeFileSync\GlobalSettings.xml"
The second error Is regarding the log file. For some reason it can't find/read the log file. In the "Const BatchFile = " I put the full path to file instead the batchfile name only. Changing this and the error disappear and the script work like a charm.

Regards,

PS: The "log file search strings" need to be change to the current language that is use. sagitario, 08 Nov 2018, 19:11
I have the same errors!
I solved the first error as sagitario said: I put the default full path and the error message disappear
But i can't solve the second error (i tried to put the full path of batchfile in Const BatchFile in vain)...
The script return this error:
line 465
Char 4
Error Invalid procedure coll or argument 'Mid'
code 800A0005
Squalo, 15 Nov 2018, 14:23
If you send me your script I can try to see what is the problem... but I notice that although I really like helping others, I do not realize much of vbscript and I do not have much free time ...
Posts: 68
Joined: 13 Aug 2018

TheExpert

@Squalo: Did you edit the script with the Windows editor notepad.exe? Then please download the script once again from the forum and edit it with Notepad++. I had the same issue and after editing the script with Notepad++ everything was fine.
Posts: 10
Joined: 15 Nov 2018

Squalo

If you send me your script I can try to see what is the problem... but I notice that although I really like helping others, I do not realize much of vbscript and I do not have much free time ... sagitario, 16 Nov 2018, 14:30
Thanks a lot, I attached the script!
PS. I set the language of freefilesync in US
@Squalo: Did you edit the script with the Windows editor notepad.exe? Then please download the script once again from the forum and edit it with Notepad++. I had the same issue and after editing the script with Notepad++ everything was fine. TheExpert, 16 Nov 2018, 18:08
No, I didn't use notepad.exe!
I only use Notepad++

Thank you all
Attachments
FreeFileSync.vbs
(22.95 KiB) Downloaded 145374 times
Posts: 19
Joined: 8 Nov 2018

sagitario

@Squalo: Did you try to put the SyncSettings.ffs_batch in the same folder of the vbscript?

I see in your file <Const BatchFile = "D:\Desktop\SyncSettings.ffs_batch">. I have already have this problem in my vbscript and I can't say you why because vbscript is not my strong. But I just managed to get it to work when I put something like this: <Const BatchFile = "SyncSettings.ffs_batch">

Hope this helps.
Posts: 10
Joined: 15 Nov 2018

Squalo

@Squalo: Did you try to put the SyncSettings.ffs_batch in the same folder of the vbscript?

I see in your file <Const BatchFile = "D:\Desktop\SyncSettings.ffs_batch">. I have already have this problem in my vbscript and I can't say you why because vbscript is not my strong. But I just managed to get it to work when I put something like this: <Const BatchFile = "SyncSettings.ffs_batch">

Hope this helps. sagitario, 19 Nov 2018, 11:05
No way!
I had already tried this way ... the result is always the same!
I don't understand why
Posts: 68
Joined: 13 Aug 2018

TheExpert

Hi all,

today I added an exception handling if there's no GlobalSettings.xml or similar named file defined: If it isn‘t defined the call procedure of FreeFileSync will be changed. I tested the exception handling successfully and hopefully it will also work for you.

And thanks to @timberetta I added the option for a SSL secured SMTP connection. I don't have the possibility to test the SSL encryption for the SMTP connection. Maybe someone else can test it and give feedback if this is working?

You' ll find the new script version here: download/file.php?id=850

Kind Regards

TheExpert
Posts: 68
Joined: 13 Aug 2018

TheExpert

@Squalo: I took a look at your script. Your issue isn't related to the batch file. You set this option with the complete path as it's documented:

" ' SET TO PATH OF [somebatchfile].ffs_batch
' IF BLANK AND NO COMMAND LINE ARGUMENT, THEN SCRIPT EXITS"

At line 465 your script is searching for the LogFolder setting in the batch file. You can define another log file folder for your synchronisation jobs. Then FreeFileSync adds the following line to the batch file: "<LogFolder>D:\LogFiles\FreeFileSync</LogFolder>" (THIS IS AN EXAMPLE!!!).

If you didn't define another log file folder maybe there's no "<LogFolder></LogFolder>" line in your batch file. You can open the batch file with Notepad++ to see if there's such a line or not.

Am I right, that there's no such a line? Then the Mid function uses the wrong string 'coordinates' and can't be executed correctly.
Posts: 10
Joined: 15 Nov 2018

Squalo

@Squalo: I took a look at your script. Your issue isn't related to the batch file. You set this option with the complete path as it's documented:

" ' SET TO PATH OF [somebatchfile].ffs_batch
' IF BLANK AND NO COMMAND LINE ARGUMENT, THEN SCRIPT EXITS"

At line 465 your script is searching for the LogFolder setting in the batch file. You can define another log file folder for your synchronisation jobs. Then FreeFileSync adds the following line to the batch file: "<LogFolder>D:\LogFiles\FreeFileSync</LogFolder>" (THIS IS AN EXAMPLE!!!).

If you didn't define another log file folder maybe there's no "<LogFolder></LogFolder>" line in your batch file. You can open the batch file with Notepad++ to see if there's such a line or not.

Am I right, that there's no such a line? Then the Mid function uses the wrong string 'coordinates' and can't be executed correctly. TheExpert, 19 Nov 2018, 21:29
You are right!! Thank you!
But now another error appears:
line 369
Char 4
Bad file name or number
code 800A0034
I tried:
-default logfolder (C:\Users\xxxx\AppData\Roaming\FreeFileSync\Logs)
-another logfolder (D:\Desktop\Logs)
the script always returns the same error.
Posts: 68
Joined: 13 Aug 2018

TheExpert

@Squalo: Please use the DoDebug option in the script and let it run once again. With this configuration the script shows you a lot of data as dialogue windows when running with wscript or in the command line when starting with cscript.

You should get the output of the log file the script wants to open at line 369. There's something wrong with the logfile. It looks like the file isn't there anymore when the script wants to open it. If you got the log file name the script found then take a look at the log file folder to see if the file is saved in this folder.
Posts: 4
Joined: 19 Nov 2018

ios

Hi,
the VBS-Script works perfect for me, but I have one question.
How can I send the report to more users?
Const MsgTo = "mail@provider.de"

Br
Ingo
Posts: 7
Joined: 29 Apr 2016

timberval

Hi,
the VBS-Script works perfect for me, but I have one question.
How can I send the report to more users?
Const MsgTo = "mail@provider.de"

Br
Ingo ios, 20 Nov 2018, 12:24
I never tried it, but I think you can do:

Const MsgTo = "mail@provider.de;mail2@provide.de"
or
Const MsgTo = "mail@provider.de,mail2@provide.de"
Posts: 10
Joined: 15 Nov 2018

Squalo

@Squalo: Please use the DoDebug option in the script and let it run once again. With this configuration the script shows you a lot of data as dialogue windows when running with wscript or in the command line when starting with cscript.

You should get the output of the log file the script wants to open at line 369. There's something wrong with the logfile. It looks like the file isn't there anymore when the script wants to open it. If you got the log file name the script found then take a look at the log file folder to see if the file is saved in this folder. TheExpert, 20 Nov 2018, 05:36
Well, I had not seen the DoDebug!
I think the problem is with
GetLogFile which returns this string:
<LogFolder>D:\Desktop\Logs</LogFolder>
instead of
D:\Desktop\Logs\FILENAME
I attach my sample batch
<?xml version="1.0" encoding="utf-8"?>
<FreeFileSync XmlType="BATCH" XmlFormat="14">
    <Compare>
        <Variant>TimeAndSize</Variant>
        <Symlinks>Exclude</Symlinks>
        <IgnoreTimeShift/>
    </Compare>
    <Synchronize>
        <Variant>Mirror</Variant>
        <DetectMovedFiles>false</DetectMovedFiles>
        <DeletionPolicy>RecycleBin</DeletionPolicy>
        <VersioningFolder Style="Replace"/>
    </Synchronize>
    <Filter>
        <Include>
            <Item>*</Item>
        </Include>
        <Exclude>
            <Item>\System Volume Information\</Item>
            <Item>\$Recycle.Bin\</Item>
            <Item>\RECYCLE?\</Item>
            <Item>*\desktop.ini</Item>
            <Item>*\thumbs.db</Item>
        </Exclude>
        <TimeSpan Type="None">0</TimeSpan>
        <SizeMin Unit="None">0</SizeMin>
        <SizeMax Unit="None">0</SizeMax>
    </Filter>
    <FolderPairs>
        <Pair>
            <Left>C:\Windows</Left>
            <Right>D:\Desktop\Nuova cartella (4)</Right>
        </Pair>
    </FolderPairs>
    <Errors Ignore="false" Retry="0" Delay="5"/>
    <LogFolder>D:\Desktop\Logs</LogFolder>
    <PostSyncCommand Condition="Completion"/>
    <Batch>
        <ProgressDialog Minimized="false" AutoClose="false"/>
        <ErrorDialog>Show</ErrorDialog>
        <PostSyncAction>None</PostSyncAction>
    </Batch>
</FreeFileSync>
Thanks a lot
Posts: 4
Joined: 19 Nov 2018

ios

Hi,
the VBS-Script works perfect for me, but I have one question.
How can I send the report to more users?
Const MsgTo = "mail@provider.de"

Br
Ingo ios, 20 Nov 2018, 12:24
I never tried it, but I think you can do:

Const MsgTo = "mail@provider.de;mail2@provide.de"
or
Const MsgTo = "mail@provider.de,mail2@provide.de" timberetta, 20 Nov 2018, 13:45
Hi,
it does not work.

Br
Ingo
Posts: 68
Joined: 13 Aug 2018

TheExpert

@Squalo: Please start the script with the DoDebug option.

Here is a sample of one of my synchronisation jobs started from the command line with cscript:
D:\Scripts>cscript FreeFileSync.vbs batchfile "Sicherung Mailserver zu HTPC.ffs_batch"
Microsoft (R) Windows Script Host, Version 5.812
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.

Argument batchfile matches BatchFile
Argument processed: sBatchFile = Sicherung Mailserver zu HTPC.ffs_batch
Executing program: "C:\Program Files\FreeFileSync\FreeFileSync.exe" "Sicherung Mailserver zu HTPC.ffs_batch" "D:\Scripts\GlobalSettings_Verification.xml"
Program execution  start time was 20.11.2018 21:24:50
Program execution completed with exitcode: 0 Synchronization completed successfully
Program execution finish time was 20.11.2018 21:26:23
GetBatchName return value = Sicherung Mailserver zu HTPC
Program elapsed seconds = 93
Elapsed Time String = 1 Minute 33 Seconds
Elapsed Numb String = 00:00 00:01:33
Log File Folder = D:\LogFiles\FreeFileSync
Job Name = Sicherung Mailserver zu HTPC
Sicherung Mailserver zu HTPC 2018-10-21 023001.092.log was created 21.10.2018 01:37:29
Sicherung Mailserver zu HTPC 2018-10-22 023001.033.log was created 22.10.2018 01:32:00
Sicherung Mailserver zu HTPC 2018-10-23 023001.495.log was created 23.10.2018 01:32:13
Sicherung Mailserver zu HTPC 2018-10-24 023001.201.log was created 24.10.2018 01:35:21
Sicherung Mailserver zu HTPC 2018-10-25 023001.371 [Fehler].log was created 25.10.2018 01:30:25
Sicherung Mailserver zu HTPC 2018-10-25 071153.115.log was created 25.10.2018 06:14:24
Sicherung Mailserver zu HTPC 2018-10-26 023001.464.log was created 26.10.2018 01:31:46
Sicherung Mailserver zu HTPC 2018-10-27 023001.299.log was created 27.10.2018 01:31:49
Sicherung Mailserver zu HTPC 2018-10-28 023001.272.log was created 28.10.2018 01:34:38
Sicherung Mailserver zu HTPC 2018-10-29 023001.473.log was created 29.10.2018 02:39:55
Sicherung Mailserver zu HTPC 2018-10-30 023001.472.log was created 30.10.2018 02:31:53
Sicherung Mailserver zu HTPC 2018-10-31 023001.216.log was created 31.10.2018 02:31:53
Sicherung Mailserver zu HTPC 2018-11-01 023001.318.log was created 01.11.2018 02:33:27
Sicherung Mailserver zu HTPC 2018-11-02 023001.307.log was created 02.11.2018 02:38:37
Sicherung Mailserver zu HTPC 2018-11-03 023001.256.log was created 03.11.2018 02:31:46
Sicherung Mailserver zu HTPC 2018-11-04 023001.283.log was created 04.11.2018 02:31:51
Sicherung Mailserver zu HTPC 2018-11-05 023001.254.log was created 05.11.2018 02:31:46
Sicherung Mailserver zu HTPC 2018-11-06 023001.752.log was created 06.11.2018 02:31:58
Sicherung Mailserver zu HTPC 2018-11-07 023001.506.log was created 07.11.2018 02:31:55
Sicherung Mailserver zu HTPC 2018-11-08 023001.435.log was created 08.11.2018 02:31:49
Sicherung Mailserver zu HTPC 2018-11-09 023000.937.log was created 09.11.2018 02:32:08
Sicherung Mailserver zu HTPC 2018-11-10 023000.963.log was created 10.11.2018 02:36:47
Sicherung Mailserver zu HTPC 2018-11-11 023001.008.log was created 11.11.2018 02:43:01
Sicherung Mailserver zu HTPC 2018-11-12 023001.100.log was created 12.11.2018 02:31:55
Sicherung Mailserver zu HTPC 2018-11-13 023000.657.log was created 13.11.2018 02:31:44
Sicherung Mailserver zu HTPC 2018-11-14 023001.287.log was created 14.11.2018 02:31:43
Sicherung Mailserver zu HTPC 2018-11-15 023001.329.log was created 15.11.2018 02:31:59
Sicherung Mailserver zu HTPC 2018-11-16 023001.286.log was created 16.11.2018 02:31:43
Sicherung Mailserver zu HTPC 2018-11-17 023001.280.log was created 17.11.2018 02:32:00
Sicherung Mailserver zu HTPC 2018-11-18 023001.216.log was created 18.11.2018 02:32:21
Sicherung Mailserver zu HTPC 2018-11-19 023001.278.log was created 19.11.2018 02:34:03
Sicherung Mailserver zu HTPC 2018-11-20 023001.350.log was created 20.11.2018 02:37:52
Sicherung Mailserver zu HTPC 2018-11-20 211119.623.log was created 20.11.2018 21:13:16
Sicherung Mailserver zu HTPC 2018-11-20 212451.372.log was created 20.11.2018 21:26:23
GetLogFile return value = D:\LogFiles\FreeFileSync\Sicherung Mailserver zu HTPC 2018-11-20 212451.372.log
GetBatchName return value = Sicherung Mailserver zu HTPC
Attempting Message Send

--------------------------------------------------------------
Subject: FreeFileSync results for batch Sicherung Mailserver zu HTPC
   From: "FreeFileSync@..." <FreeFileSync@...>
     To: "...@..." <...@...>
--------------------------------------------------------------
FreeFileSync batch Sicherung Mailserver zu HTPC running on WIN10SERVER
Synchronization completed successfully

Duration: 1 Minute 33 Seconds



Log File: D:\LogFiles\FreeFileSync\Sicherung Mailserver zu HTPC 2018-11-20 212451.372.log
--------------------------------------------------------------
Sleeping 15 seconds before exiting.
Maybe you can paste the output of your running script here?
Posts: 10
Joined: 15 Nov 2018

Squalo

@TheExpert Sorry, i didn’t explain well.
i enabled dodebug and the error is in GetLogFolder
Executing program: "D:\Program Files\FreeFileSync\FreeFileSync.exe" "D:\Desktop\SyncSettings.ffs_batch" "%appdata%\FreeFileSync\GlobalSettings.xml"
Program execution  start time was 20/11/2018 22:18:23
Program execution completed with exitcode: 3 Synchronization was aborted
Program execution finish time was 20/11/2018 22:18:49
GetBatchName return value = SyncSettings
Program elapsed seconds = 26
Elapsed Time String = 26 Seconds
Elapsed Numb String = 00:00 00:00:26
Log File Folder = D:\Desktop\Logs
Job Name = D:\Desktop\SyncSettings
GetLogFile return value =     <LogFolder>D:\Desktop\Logs</LogFolder>
Scanning Log File
d:\Download\freefilesync.vbs(369, 4) Errore di run-time di Microsoft VBScript: Nome o numero di file non valido
Posts: 68
Joined: 13 Aug 2018

TheExpert

@Squalo: I don't have an idea why the script recognizes
GetLogFile return value =     <LogFolder>D:\Desktop\Logs</LogFolder>
instead of
GetLogFile return value = D:\Desktop\Logs
When you start this synchronization job directly with FreeFileSync, does the job work and is there a log file?

I see that it is aborted:
Program execution completed with exitcode: 3 Synchronization was aborted
Maybe it's also a good idea to download the newest script version and retry it again.
Posts: 10
Joined: 15 Nov 2018

Squalo

When you start this synchronization job directly with FreeFileSync, does the job work and is there a log file? TheExpert, 21 Nov 2018, 05:14
Yes, the job works fine!
I see that it is aborted:
Program execution completed with exitcode: 3 Synchronization was aborted
TheExpert, 21 Nov 2018, 05:14
I stop it to generate errors.
Maybe it's also a good idea to download the newest script version and retry it again. TheExpert, 21 Nov 2018, 05:14
What's the latest version? I use Version: 2018.10.20 - Version 1.13

Now I'll try to set it all up again.
Posts: 7
Joined: 29 Apr 2016

timberval

Hi,
the VBS-Script works perfect for me, but I have one question.
How can I send the report to more users?
Const MsgTo = "mail@provider.de"

Br
Ingo ios, 20 Nov 2018, 12:24
I never tried it, but I think you can do:

Const MsgTo = "mail@provider.de;mail2@provide.de"
or
Const MsgTo = "mail@provider.de,mail2@provide.de" timberetta, 20 Nov 2018, 13:45
Hi,
it does not work.

Br
Ingo ios, 20 Nov 2018, 13:54
Hi ios
it doesn't work: did you receive an error? doesn't work for all address or you receive only one?
I made a test in this way and i received correctly the report for 2 address:
Const MsgTo = "aaaa@xxxxxx.it;bbbb@yyyyyyyyy.it"
Try to test again.
Posts: 68
Joined: 13 Aug 2018

TheExpert

Maybe it's also a good idea to download the newest script version and retry it again. TheExpert, 21 Nov 2018, 05:14
What's the latest version? I use Version: 2018.10.20 - Version 1.13

Now I'll try to set it all up again. Squalo, 21 Nov 2018, 11:51
As written on 19 Nov 2018, there's a new version available. Here's the download link once again: download/file.php?id=850.
Posts: 19
Joined: 8 Nov 2018

sagitario

@sagitario: Did you have a chance to test the SSL connection to your mail server after adding the lines timbretta added in his post above? Is it working? I hope I will have the time to build a new script at this weekend and will then add the SSL feature to the new script version. TheExpert, 14 Nov 2018, 09:05
Yes.. it work.
Posts: 68
Joined: 13 Aug 2018

TheExpert

@Squalo: I was confused today in the early morning. I think I found out the issue.

These outputs of your script are incorrect:
Job Name = D:\Desktop\SyncSettings
GetLogFile return value =     <LogFolder>D:\Desktop\Logs</LogFolder>
They should look like:
Job Name = Sicherung Mailserver zu HTPC
GetLogFile return value = D:\LogFiles\FreeFileSync\Sicherung Mailserver zu HTPC 2018-11-20 212451.372.log
Because of the incorrect job name the script doesn't find a log file. And the job name is a result of the batch file name without the file extension. You are using the complete path of the batch file and this is correct as Lars Beneke as the script originator documented. But the string procedures do not work when configuring the complete path to the batch file.

It looks like you are the first one, who is using different locations for batch files and the script.

Please try the synchronization once again with saving the script in the same location where the batch files are saved and set only the name of the batch file instead of the complete path. With these settings the script should work as expected. Does it work?
Posts: 68
Joined: 13 Aug 2018

TheExpert

@sagitario: Did you have a chance to test the SSL connection to your mail server after adding the lines timbretta added in his post above? Is it working? I hope I will have the time to build a new script at this weekend and will then add the SSL feature to the new script version. TheExpert, 14 Nov 2018, 09:05
Yes.. it work. sagitario, 21 Nov 2018, 15:40
Thank you for testing :-)

After I released a new version of this script on Monday with the SSL encryption option this new script version should work, too.
Posts: 10
Joined: 15 Nov 2018

Squalo

@Squalo: I was confused today in the early morning. I think I found out the issue.

These outputs of your script are incorrect:
Job Name = D:\Desktop\SyncSettings
GetLogFile return value =     <LogFolder>D:\Desktop\Logs</LogFolder>
They should look like:
Job Name = Sicherung Mailserver zu HTPC
GetLogFile return value = D:\LogFiles\FreeFileSync\Sicherung Mailserver zu HTPC 2018-11-20 212451.372.log
Because of the incorrect job name the script doesn't find a log file. And the job name is a result of the batch file name without the file extension. You are using the complete path of the batch file and this is correct as Lars Beneke as the script originator documented. But the string procedures do not work when configuring the complete path to the batch file.

It looks like you are the first one, who is using diferent locations for batch files and the script.

Please try the synchronization once again with saving the script in the same location where the batch files are saved and set only the name of the batch file instead of the complete path. With these settings the script should work as expected. Does it work? TheExpert, 21 Nov 2018, 15:58
I understand where is the problem, but I do not even understand why this error occurs!
I tried latest version 1.14 md5 checksum 8094f2b903ab056cc1a9c8ff39250b35 with same result!
Everytime i reach same results
Job Name = D:\Desktop\SyncSettings
GetLogFile return value =     <LogFolder>D:\Desktop\Logs</LogFolder>
I tried to create new batch, different folder, complete the task correctly (without stop)