Knil92 Posted March 1, 2016 Posted March 1, 2016 Hey, I was wondering if some one can take a look at these scripts I'm using and tell me what you think. So basically it runs the dir command and then creates a text file with the results and then e-mails the results to us. This is so we can put it in the backup folder for SIMS and have it e-mail us so that we can see if the backup script is running correctly. So yeah, here's the code; Batch script; @echo off dir /o:-d >> dir.txt start gmail.vbs ping localhost -n 8 >nul del dir.txt this creates a text file called dir.txt with contains the results from running the dir command in command prompt VBS Script; on error resume next Const schema = "http://schemas.microsoft.com/cdo/configuration/" Const cdoBasic = 1 Const cdoSendUsingPort = 2 Dim oMsg, oConf ' E-mail properties Set oMsg = CreateObject("CDO.Message") oMsg.From = "[email protected]" ' or "Sender Name " oMsg.To = "[email protected]" ' or "Recipient Name " oMsg.Subject = "Database Backup Checker - SchoolName" oMsg.TextBody = CreateObject("Scripting.filesystemObject").OpenTextFile("dir.txt", 1).ReadAll ' GMail SMTP server configuration and authentication info Set oConf = oMsg.Configuration oConf.Fields(schema & "smtpserver") = "smtp.gmail.com" 'server address oConf.Fields(schema & "smtpserverport") = 465 'port number oConf.Fields(schema & "sendusing") = cdoSendUsingPort oConf.Fields(schema & "smtpauthenticate") = cdoBasic 'authentication type oConf.Fields(schema & "smtpusessl") = True 'use SSL encryption oConf.Fields(schema & "sendusername") = "[email protected]" 'sender username oConf.Fields(schema & "sendpassword") = "placepasswordhere" 'sender password oConf.Fields.Update() ' send message oMsg.Send() The batch file, once it creates the dir.txt, runs the vbscript which reads the dir.txt file and uses that as the body of text for the e-mail that it sends out. We use this on schools that we support to just double check that the backups are running correctly and have it scheduled to run once a month. Pretty much all of our schools that we support use windows servers so it can run the vbscript and the batch file with out any extras needing to be installed. So yeah, tell me what you think, and any feed back would be helpful.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now