We would issue remote shutdown commands and sometimes
the system wouldn't completely shutdown and it went into the undead state.
Anyone connected to the machine still worked but no new connections allowed
and no access to the console. Found out from Microsoft the shutdown command
isn't the greatest and so I wrote a VBScript that has resolved the issue.
This isn't the greatest code in the world, I should correct it so the values
are all defined in the variables section but use it if you find value to it.
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''
' Program - RemoteReboot.vbs '
' Author - Paul Bergson '
' Date Written - 08/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") =
"Yoursmtp.YourDomain.com"
..Update
End With
strHTML = strComputer & " has been automatically rebooted by YourServerName"
_
& " on " & FormatDateTime(Date(),1) & ", " & FormatDateTime(Time(),3)
strSubject = strComputer & " has been rebooted"
With iMsg
Set .Configuration = iConf
..To = "Notification
[email protected]" ' Destination e-mail address
..From = "
[email protected]"
..Subject = strSubject
..HTMLBody = strHTML
..Send
End With
set imsg = Nothing
set iconf = Nothing