Guest User

Shut-downWithInfo

a guest
Dec 20th, 2014
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Set wshShell = WScript.CreateObject( "WScript.Shell" )
  2. ComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
  3.  
  4.  
  5.  
  6.  
  7. Set emailObj      = CreateObject("CDO.Message")
  8.  
  9. emailObj.From     = "AnyEmailWorksHere" 'Any email should work here
  10. emailObj.To       = "[email protected]" 'Enter the email that you want the shut-down message sent to
  11.  
  12. emailObj.Subject  = "Shut-down Complete." 'This is the subject line of the email
  13. emailObj.TextBody = "The System " & ComputerName & "  successfully shut-down @ " & Time & ", " & Date
  14. 'The body of the email,
  15.                                                                                                     'I have it set up to tell me the
  16.                                                                                                     'time and date of the shut-down,
  17.                                                                                                     'as well as the PC name but you
  18.                                                                                                     'can make it say whatever you
  19.                                                                                                     'want
  20.  
  21. Set emailConfig = emailObj.Configuration
  22.  
  23. emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
  24. emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
  25. emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing")    = 2  
  26. emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1  
  27. emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl")      = true
  28. emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername")    = "YourEmailAdressHere"
  29. 'Enter your email                                                                                      
  30.  
  31. 'address, I have the
  32.                                                                                                              'rules setup for gmail
  33.                                                                                                              'but you just need to
  34.                                                                                                              'change the smtp settings
  35.                                                                                                              'to your likings
  36.                                                                                                              
  37. emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")    = "PasswordHere" 'Pretty self explanatory your email pass here
  38.  
  39. emailConfig.Fields.Update
  40.  
  41. emailObj.Send
  42.  
  43.  
  44. 'The following part does the actual shutting down of the computer
  45. dim strShutDown,objShell
  46. strShutdown = "shutdown.exe -s -t 0 -f -m \\" & strComputer
  47. set objShell = CreateObject("WScript.Shell")  
  48. objShell.Run strShutdown, 1, false
Advertisement
Add Comment
Please, Sign In to add comment