0

I've been trying to write a post-lock hook for my VisualSVN server on Windows, using batch files and VBS scripts. The end goal is to have the hook email a list of all the locked files to a collection of email addresses. However, the hook is called for every file. I'm hoping there's a way around this, or a clever way of waiting for all the information before sending the email. Also, I want a list of all the files, but currently only the repo path is passed in. I know the file paths are passed via stdin, but I haven't found a way to get that into a string to be passed to my VBS file. Any help would be great.

Batch File:

@echo off
pushd %~dp0
cscript email-bat.vbs %2 LOCKED %1
@pause 5

VBS:

Set emailObj      = CreateObject("CDO.Message")
Set args = WScript.Arguments

emailObj.From     = "mymail@gmail.com"
emailObj.To       = "tomail@gmail.com"

emailObj.Subject  = "SVN " + args.Item(1)
emailObj.TextBody = args.Item(0) + " has " + args.Item(1) + " the file(s) " + args.Item(2) + "."

Set emailConfig = emailObj.Configuration

emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing")    = 2  
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1  
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl")      = true 
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername")    = "mymail@gmail.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")    = "password"

emailConfig.Fields.Update

emailObj.Send
JamesT
  • 47
  • 2
  • 9
  • 1. Collect all items to send: `echo %2 LOCKED %1>>mailbody.txt` 2. Adapt your `email-bat.vbs` to accept this call: `cscript email-bat.vbs "%~dp0mailbody.txt"` and call it no sooner than all items are collected. 3. Not more to say without knowing source and other circumstances for `%1` and `%2` arguments in your Batch File... – JosefZ Feb 18 '15 at 20:32
  • The problem is, I have no way of knowing when all the items are collected. The batch files are called individually. – JamesT Feb 19 '15 at 10:36
  • I thought you know it asking for _a clever way of waiting for all the information before sending the email_. So collect them continuously and schedule `cscript email-bat.vbs` to send collected currently if any and then empty `mailbody.txt` file. Schedule with a desired appropriate frequency – JosefZ Feb 19 '15 at 10:51

0 Answers0