Shell Scripting: Windows

Posted: March 2nd, 2004 | Author: telcor | Filed under: WSH | No Comments »

Ever wonder:

  • How to use VBScript to automate a task?
  • How to send an e-mail using VBScript?
  • How WSH could allow more control in Administrating systems?

Starting with this site: Microsoft Windows 2000 Scripting Guide

There is lots of great stuff in there, for example this little gem on sending an e-mail:

Set objEmail = CreateObject("CDO.Message")
objEmail.From = "admin1@fabrikam.com"
objEmail.To = "admin2@fabrikam.com"
objEmail.Subject = "Server down"
objEmail.Textbody = "Server1 is no longer accessible over the network."
objEmail.Configuration.Fields.Item _
 ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
 ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"MySMTPHost"
objEmail.Configuration.Fields.Item _
 ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send

And yes, the above works even on a machine without direct access to the Internet, as long as it has access to a SMTP server.