Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script to get notified when a Xp computer rebooted

Status
Not open for further replies.

scriptnewbie

IS-IT--Management
Jul 22, 2005
16
US
I would be grateful to get some help on how to write 2 scripts to send me an email when:
1/ an XP computer rebooted.
2/ when a user logs on.
Thank you
 
This script can be set as a startup script to notify of the reboot. For the login, simply edit the script a bit and set as a login script instead.

Code:
'==========================================================================
'
' VBScript Source File -- 
'
' NAME: NotifyReboot.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/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 = "192.168.1.1" 
' 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 = "[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing",[/URL] _
cdoSendUsingPort = 2, _
cdoSMTPServer = "[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver"[/URL]

' 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 Attachment

'Send the message.
iMsg.Send 

MsgBox "Done"

I hope you find this post helpful.

Regards,

Mark
 
Thanks for your response Mark!
This script would not be feasible since I have computers scattered all over places. physically placing this script on those pcs is not an option. I would like the to run a script from my local machine an "LISTEN' out to the network and alert me when a computer is rebooted. and when a user logs on.

Thanks
 
All you need to do is add the script to a policy and it will get pushed out to each of the machines.

I hope you find this post helpful.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top