Results 1 to 3 of 3

Thread: script for checking graceful and unexpected reboot in windows server

  1. #1
    Join Date
    May 2010
    Posts
    2

    sad script for checking graceful and unexpected reboot in windows server

    Hi,

    Can anybody provide me the script (VBscript) to check the windows server reboot type, i.e whether the last reboot was a graceful or unexpected.

    The script may trap the value (Event ID:6008 = unexpected and Event ID:6006= graceful) from system eventlog and flash the msg. (ref: below)

    Or if there is any registry key from where it can be checked, then fine.


    Event Type: Error
    Event Source: EventLog
    Event Category: None
    Event ID: 6008
    Date: 20/05/2010
    Time: 08:30:53
    User: N/A
    Computer: ABC
    Description:
    The previous system shutdown at 19:01:39 on 19/05/2010 was unexpected.

    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.


    Event Type: Information
    Event Source: EventLog
    Event Category: None
    Event ID: 6006
    Date: 20/05/2010
    Time: 04:15:13
    User: N/A
    Computer: ABC
    Description:
    The Event log service was stopped.

    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

  2. #2
    Join Date
    Dec 2007
    Posts
    1,736

    Re: script for checking graceful and unexpected reboot in windows server

    If you can type "gpedit.msc" in run dialog box and going to local computer setting> Computer Configuration > Windows Settings > Scripts start-up/shutdown, then you can see all the batch files here and then you can add your files, otherwise use the below script.

    iEventID1 = "'20142'"
    iEventID2 = "'20189'"

    Set objWMIService = GetObject("winmgmts:{(Security)}\\.\root\cimv2")
    Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
    ("Select * from __InstanceCreationEvent Where " _
    & "TargetInstance ISA 'Win32_NTLogEvent' " _
    & "and (TargetInstance.EventCode = " & iEventID1 _
    & "or TargetInstance.EventCode = " & iEventID2 & ")")

    Do
    Set objLatestEvent = colMonitoredEvents.NextEvent
    SendMessage objLatestEvent.TargetInstance.Message, objLatestEvent.TargetInstance.EventCode
    Loop

  3. #3
    Join Date
    May 2010
    Posts
    2

    Re: script for checking graceful and unexpected reboot in windows server

    James,

    Thanks for reply. But the script is not working. It keeps on executing, without any msg. I just need to check only the last reboot type (planned or unexpected) through VB script.

    Please clarify what is iEventID1 = "'20142'" and iEventID2 = "'20189'".

    Please assist.

Similar Threads

  1. Event ID 1076 Reason Code: 0xa000000 server unexpected reboot
    By goatbernard in forum Windows Server Help
    Replies: 4
    Last Post: 30-12-2013, 11:03 AM
  2. Windows server 2003 unexpected reboot
    By Roberto R in forum Windows Server Help
    Replies: 7
    Last Post: 31-08-2011, 11:57 PM
  3. Replies: 1
    Last Post: 06-04-2010, 09:36 PM
  4. Unexpected Restarts in Windows Server 2003
    By quaium in forum Windows Server Help
    Replies: 4
    Last Post: 03-06-2008, 05:55 PM
  5. Windows 2003 Server Unexpected Shutdown
    By jlm in forum Windows Server Help
    Replies: 4
    Last Post: 01-03-2007, 02:57 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,230,058.73287 seconds with 17 queries