Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set wshShell = WScript.CreateObject( "WScript.Shell" )
- ComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
- Set emailObj = CreateObject("CDO.Message")
- emailObj.From = "AnyEmailWorksHere" 'Any email should work here
- emailObj.Subject = "Shut-down Complete." 'This is the subject line of the email
- emailObj.TextBody = "The System " & ComputerName & " successfully shut-down @ " & Time & ", " & Date
- 'The body of the email,
- 'I have it set up to tell me the
- 'time and date of the shut-down,
- 'as well as the PC name but you
- 'can make it say whatever you
- 'want
- Set emailConfig = emailObj.Configuration
- emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
- emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
- emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
- emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
- emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
- emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "YourEmailAdressHere"
- 'Enter your email
- 'address, I have the
- 'rules setup for gmail
- 'but you just need to
- 'change the smtp settings
- 'to your likings
- emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "PasswordHere" 'Pretty self explanatory your email pass here
- emailConfig.Fields.Update
- emailObj.Send
- 'The following part does the actual shutting down of the computer
- dim strShutDown,objShell
- strShutdown = "shutdown.exe -s -t 0 -f -m \\" & strComputer
- set objShell = CreateObject("WScript.Shell")
- objShell.Run strShutdown, 1, false
Advertisement
Add Comment
Please, Sign In to add comment