Contributed By: Captive [email protected]
Submitted On: 16/03/03
Rem>----------------------------------------------------------------------
Rem>' ** Macro Scheduler update checker ** v1.00 - 13/Mar/2002
Rem>' ** Written by Captive
Rem>'
Rem>' This script will download the file "mscver.txt" from the mjtnet.com
Rem>' ftp site, and extract the value contained for the latest version.
Rem>' It will compare the result to what version you have running.
Rem>----------------------------------------------------------------------
Rem>'--------------------------------------------------------
Rem>'* !!!!!!! Here are some variables you can edit !!!!!!! *
Rem>'--------------------------------------------------------
Rem>'The folder we temporarily save our "_msver.txt" to. You only need to
Rem>' adjust this if you do not have permission to read/write files in the
Rem>' normal temp directory.
Let>sTempFolder=%TEMP_DIR%
Rem>' What action to perform when a new version is available?
Rem>' 0 = Disabled, 1 = Enabled
Rem>' DoEmail ... Send an email to the address listed below
Let>bDoEmail=0
Rem' DoMessagebox ... Show a message box
Let>bDoMessagebox=1
Rem>' The email address we can notify if a new version exists.
Let>sEmailAddress=[email protected]
Rem> *****
Rem>' For email to work, you *must* change this to an SMTP server you can use.
Rem>' This will normally be something like mail.yourisp.com
Let>sSMTPServer=mail.yourisp.com
Rem>' The address this email will be 'from' - some ISPs will only let
Rem>' you send emails with a valid 'from' email address.
Rem>' - By default, use the same address we are sending to
Let>sFromEmail=%eMailAddress%
Rem>'--------------------------------------------------------
Rem>'** Do not edit below this point, unless you know what you are doing!
Rem>'--------------------------------------------------------
Let>VAREXPLICIT=1
Rem>'--------------------------------------------------------
Rem>' Check if the temp dir exists.
Rem>'--------------------------------------------------------
IfFileExists>%sTempFolder%\\_msver.txt,DeleteVerFile
IfDirExists>%sTempFolder%,FetchVerFile
Message>The directory:%CRLF%"%sTempFolder%\"%CRLF%does not exist. Script terminated!
Goto>TheEnd
Rem>'--------------------------------------------------------
Rem>' Delete the temp file
Rem>'--------------------------------------------------------
Label>DeleteVerFile
DeleteFile>%sTempFolder%\\_msver.txt
IfFileExists>%sTempFolder%\\_msver.txt,FailedDeleteVerFile
Goto>FetchVerFile
Rem>'--------------------------------------------------------
Rem>' If we were unable to delete the tmp file, show an error then exit.
Rem>'--------------------------------------------------------
Label>FailedDeleteVerFile
Message>Failed to delete the file:%CRLF%"%sTempFolder%\\_msver.txt"%CRLF%Script terminated!
Goto>TheEnd
Rem>'--------------------------------------------------------
Rem>' Fetch the mscver.txt file from the MSched web site.
Rem>'--------------------------------------------------------
Label>FetchVerFile
Let>FTP_STATUS=0
FTPGetFile>ftp.mjtnet.com,anonymous,[email protected],21,%sTempFolder%\\_msver.txt,/pub/mscver.txt,A
If>%FTP_RESULT%=Success,CheckVerFileExists
Let>MSG_STAYONTOP=1
Message>The result of FTPGetDirList is:%CRLF%%FTP_RESULT%%CRLF%Script terminated!
Goto>TheEnd
Rem>'--------------------------------------------------------
Rem>' Double check, does the file actually exist?
Rem>'--------------------------------------------------------
Label>CheckVerFileExists
IfFileExists>%sTempFolder%\\_msver.txt,CompareVer
Message>The file:%CRLF%"%sTempFolder%\\_msver.txt"%CRLF%does not exist. Script terminated!
Goto>End
Rem>'--------------------------------------------------------
Rem>' Extract the text on the first line, put it in to %sLine%
Rem>'--------------------------------------------------------
Label>CompareVer
ReadLn>%sTempFolder%\\_msver.txt,1,sLine
DeleteFile>%sTempFolder%\\_msver.txt
Rem>' Extract the text from the 50th character and up, put it in %sLatest%
MidStr>%sLine%,50,15,sLatest
If>%sLatest%=%MSCHED_VER%,Latest,DiffAvail
Rem>'--------------------------------------------------------
Rem>' ** You have the lastest version. **
Rem>'--------------------------------------------------------
Label>Latest
Rem>'- The following line is disabled so the macro will exit silently
Rem>Message>You are running the latest version of Macro Scheduler: %sLatest%
Goto>TheEnd
Rem>'--------------------------------------------------------
Rem>' ** A different version is available! **
Rem>'--------------------------------------------------------
Label>DiffAvail
Let>sLineA=A different version of Macro Scheduler is available!
Let>sLineB=Version available: %sLatest%
Let>sLineC=You are running version %MSCHED_VER%
If>%bDoEmail%=1,DoActEmail
If>%bDoMessagebox%=1,DoActMessagebox,TheEnd
Rem>' Send the email.
Label>DoActEmail
Let>SENDMAIL_STATUS=0
Let>sFromName=MSchedCheck4Update Macro
Let>sEmailSubject=A different version of Macro Scheduler is available (%sLatest%)
Let>sEmailBodyL1=%CRLF%This email was sent to you by the MSchedCheck4Update Macro%CRLF%
Let>sEmailBody=%sLineA%%CRLF%%sLineB%%CRLF%%sLineC%%CRLF%%sEmailBodyL1%
SMTPSendMail>%eMailAddress%,%sSMTPServer%,%sFromEmail%,%sFromName%,%sEmailSubject%,%sEmailBody%,
Let>SENDMAIL_STATUS=1
Rem>Message>Result of SendMail: %SMTP_RESULT%
If>%bDoMessagebox%=1,DoActMessagebox,TheEnd
Rem>' The message box
Label>DoActMessagebox
Message>%sLineA%%CRLF%%sLineB%%CRLF%%sLineC%
Goto>TheEnd
Rem>'--------------------------------------------------------
Label>TheEnd
Macro to check for updates of MSched
Moderators: Dorian (MJT support), JRL, Phil Pendlebury
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact: