This one might be easier for you to understand as it has been fully commented. Save the following to a text file and give it an extension of
.VBS.
You can edit it with notepad and read the comments which all begin with an apastrophe.
You will need to change just a few lines. You need to put in your domain name, who you want the message sent to, the IP address of your SMTP server and you will need to edit the message body and attachment info. Should all be easy enough to follow.
For your SMTP server, take a look in the properties of your Outlook Email account. If you use POP mail, enter the Outgoing SMTP server name instead of entering an IP address. If you are using an Exchange server, you could try entering that name. You may need to speak to your network admin to allow you to relay to the server.
'==========================================================================
'
' VBScript Source File --
'
' NAME: NotifyReboot.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL:
' DATE : 02/13/2003
'
' COMMENT:
'
' This script can be added to a machines startup script in Group Policy to notify
' an e-mail address that the machine has restarted.
'
' You must customize the entries for oDomain, oMyIP and oTo with the proper company information.
' Items to customize are on lines 29, 31 and 33.
'=====================================
Dim oName, ODomain, oMyIP, oTo
' Get the computer name
Set WshNetwork = CreateObject("WScript.Network")
oName = WshNetwork.ComputerName
' Set the company specific information
' Company Internet Domain Name
ODomain = "thespidersparlor.com"
' Set the SMTP server IP
oMyIP = "68.6.19.4"
' Where do you want the message to be delivered
oTo = "markdmac@thespidersparlor.com"
' Set the visual basic constants as they do not exist within VBScript.
' Do not set your smtp server information here.
Const cdoSendUsingMethod = "
_
cdoSendUsingPort = 2, _
cdoSMTPServer = "
'// Create the CDO connections.
Dim iMsg, iConf, Flds
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
'// SMTP server configuration.
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort
'// Set the SMTP server address here.
.Item(cdoSMTPServer) = oMyIP
.Update
End With
'// Set the message properties.
With iMsg
Set .Configuration = iConf
.To = oTo
.From = oName & "@" & oDomain
.Subject = "Server Reboot"
.TextBody = "Server " & oName & "at company " & ODomain & " was restarted " & now
End With
'// An attachment can be included.
iMsg.AddAttachment "C:\Attachment.txt"
'Send the message.
iMsg.Send
MsgBox "Done"
I hope you find this post helpful. Please let me know if it was.
Regards,
Mark