I would suggest you reconsider using the shutdown command. I have had a lot
machines go stupid where they hang in the reboot process and you will
eventually have to hit the power switch to get them restarted. It is
intermittent and it works most of the time but I have since written a script
with an e-mail notification when it is rebooted.
I create a vbs from the script below (Make sure to replace the Your computer
name and your domain name) and enter it in the scheduled task as:
cscript e:\scriptname.vbs computerToReboot
We have many machines all scheduled using this same task (All run from a
single administrative machine) and are e-mailed when the reboot occurs. I
have never had an error since going this route.
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''
' Program - RemoteReboot.vbs '
' Author - Paul Bergson '
' Date Written - 04/15/07 '
' Description - Is a more drastic remote reboot '
''''''''''''''''''''''''''''''''''''''''''''''''''
Dim OpSysSet
Dim OpSys
Dim strComputer
Dim iMsg
Dim iConf
Dim Flds
Dim strSubject
Dim strHTML
on error resume next
strComputer = WScript.Arguments.Item(0) 'Get server name
If WScript.Arguments.Count = 1 Then
Set OpSysSet = GetObject("winmgmts:{(Shutdown)}\\" _
& strComputer _
& "\root\cimv2").ExecQuery("select * from Win32_OperatingSystem where
Primary=true")
For Each OpSys in OpSysSet
OpSys.Reboot()
Next
Else
Wscript.Echo "Server Name required. Reboot operation Aborted!"
Wscript.Quit
End If
'Send out an e-mail on the reboot
set imsg = createobject("cdo.message")
set iconf = createobject("cdo.configuration")
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
.Update
End With
strHTML = strComputer & " has been automatically rebooted by Your Computer
Name" _
& " on " & FormatDateTime(Date(),1) & ", " & FormatDateTime(Time(),3)
strSubject = strComputer & " has been rebooted"
With iMsg
Set .Configuration = iConf
.To = "NotificationName@YourDomain.com" ' Destination e-mail address
.From = "YourComputerName@YourDomain.com"
.Subject = strSubject
.HTMLBody = strHTML
.Send
End With
set imsg = Nothing
set iconf = Nothing
--
Paul Bergson
MVP - Directory Services
MCT, MCSE, MCSA, Security+, BS CSci
2008, 2003, 2000 (Early Achiever), NT4
http://www.pbbergs.com
Please no e-mails, any questions should be posted in the NewsGroup
This posting is provided "AS IS" with no warranties, and confers no rights.