Validate the executions of a bat fi

Microsoft / Hp dl 380
January 28, 2009 at 16:36:11
Specs: Windows 2003 Advanced Server , 3.4 GHz 2 GB Ram
Hello,

I have a current batch file that runs every five minutes to move files from one server to the other. This job is running through the standard Windows Scheduler.

My question is two fold. How can I validate that the output message of my script:echo Completed copy of irr directory successfully at %date% %time% >> synchHHSC.log is generated? Also, how can I e-mail a message if the date time has not been updated. My thought was to run another bat file every 15 minutes to check for the latest time stamp, but I don't know how to set the commands to look for sysdate is greater than sysdate -10 minutes.

Any input would be helpful...also, here's the entire script as I am outputting to two seperate log files.

date /t >> synchhsc.log
time /t >> synchhsc.log
@echo off
echo this script will copy over all of the media files from the
echo Austin SDDSN server to the San Angelo side.
echo press any key to continue, ctrl-C to exit

xcopy d:\media\dir\irr\en-us\hhsc\*.* \\x.x.x.x\d$\media\dir\irr\en-us\hhsc\ /s /c /y
echo Completed copy of irr directory successfully at %date% %time% >> synchHHSC.log


Thank you,
Brian


See More: Validate the executions of a bat fi

Report •


#1
January 28, 2009 at 19:43:23
This VBScript goes purely by the file's modified time, so you'll probably want to edit that script to remove the first two lines.

'Note: Script assumes log file will be there. Script'll crash if it isn't.
Const logName    = "synchhsc.log"
      timeout    = 15 / (24 * 60) '15 minutes
Const emailTo    = "you@whereever.com"
Const emailFrom  = "you@whereever.com"
Const emailSbjct = "Log file issues"
Const SMTPServer = "smtp.whereever.com"
Const SMTPPort   = 25
Const emailUsr   = "you"
Const emailPsswd = "yourPassword"
Const emailSSL   = False
      emailMsg   = "Issues w/ " & logName


With CreateObject("Scripting.FileSystemObject").GetFile(logName)
  emailMsg = emailMsg & vbNewLine & "Mod: " & .DateLastModified
  If .DateLastModified < (Now - timeout) Then _
    SendEmail
End With

Sub SendEmail
  Const cfg = "http://schemas.microsoft.com/cdo/configuration/"
  With CreateObject("CDO.Message")
    .From                                  = emailFrom
    .To                                    = emailTo
    .Subject                               = emailSbjct
    .TextBody                              = emailMsg
    With .Configuration.Fields
      .Item(cfg & "sendusing")             = 2
      .Item(cfg & "smtpserver")            = SMTPServer
      .Item(cfg & "smtpserverport")        = SMTPPort
      .Item(cfg & "smtpconnectiontimeout") = 60
      .Item(cfg & "smtpauthenticate")      = 1
      .Item(cfg & "smtpusessl")            = emailSSL
      .Item(cfg & "sendusername")          = emailUsr
      .Item(cfg & "sendpassword")          = emailPsswd
      .Update
    End With
    .Send
  End With
  WScript.Echo "Done"
End Sub


Report •

#2
January 29, 2009 at 13:55:17
Would I end up running this vbs file in the same directory. Where you specify (logName) I will enter in my log file, but I wanted to make sure that I didn't need to put the path of the file in.

Report •

#3
January 29, 2009 at 14:15:46
Woops...I totally missed the command - Const logName = "synchhsc.log" at the top...silly me...

Report •

Related Solutions

#4
January 29, 2009 at 14:42:02
I end up getting an error of
Line: 39
Char: 5
Error: The "SendUsing" configuration is invalid.

Code: 80040220
Source: CDO.Message.1

When I look this up on the MS website I find a couple of examples that don't relate to what's loaded on the server. There is on item where it refers to pickup directories, but that's not what's going on here. The server has IIS 4 on a Windows 2000 Adv Server.

Not sure what my next steps might be.


Report •

#5
January 30, 2009 at 03:00:21
Some quick research suggests it might be a configuration issue/conflict.

The research also came up with some actions. First, you can re-register CDO with:

REGSVR32 CDO.DLL

I also wrapped the script up in a .WSF, so if it is a conflict, hopefully the script crashes much sooner/works:

<job>
  <object id="cdo" clsid="{CD000001-8B95-11D1-82DB-00C04FB1625D}" />
  <script language="VBScript">
    'Note: Script assumes log file will be there. Script'll crash if it isn't.
    Const logName    = "synchhsc.log"
          timeout    = 15 / (24 * 60) '15 minutes
    Const emailFrom  = "you@whereever.com"
    Const emailTo    = "you@whereever.com"
    Const emailSbjct = "Log file issues"
    Const SMTPServer = "smtp.whereever.com"
    Const SMTPPort   = 25
    Const emailUsr   = "you"
    Const emailPsswd = "yourPassword"
    Const emailSSL   = False
          emailMsg   = "Issues w/ " & logName


    'With CreateObject("Scripting.FileSystemObject").GetFile(logName)
    '  emailMsg = emailMsg & vbNewLine & "Mod: " & .DateLastModified
    '  If .DateLastModified < (Now - timeout) Then _
    '    SendEmail
    'End With
    SendEmail

    Sub SendEmail
      Const cfg = "http://schemas.microsoft.com/cdo/configuration/"
      With cdo
        .From                                  = emailFrom
        .To                                    = emailTo
        .Subject                               = emailSbjct
        .TextBody                              = emailMsg
        With .Configuration.Fields
          .Item(cfg & "sendusing")             = 2
          .Item(cfg & "smtpserver")            = SMTPServer
          .Item(cfg & "smtpserverport")        = SMTPPort
          .Item(cfg & "smtpconnectiontimeout") = 60
          .Item(cfg & "smtpauthenticate")      = 1
          .Item(cfg & "smtpusessl")            = emailSSL
          .Item(cfg & "sendusername")          = emailUsr
          .Item(cfg & "sendpassword")          = emailPsswd
          .Update
        End With
        '.Send
      End With
      WScript.Echo "Done"
    End Sub
  </script>
</job>

I'm sorry I'm not more help in this; the only systems I have access to are WinXP and up.


Report •


Ask Question