none
Popup to check for pending restart RRS feed

  • Question

  • I'm trying to create a VBS script that checks if a reboot is pending and if so it pops up a message giving the user the option to reboot or to cancel. Does anyone know hwy this is not working?

    Thanks,

    Josh

    Set objSysInfo = CreateObject("Microsoft.Update.SystemInfo")
    If objSysInfo.RebootRequired Then

    Result = intAnswer = _
        Msgbox("A Reboot is pending, Press ""OK"" to reboot now or ""Cancel"" to reboot later", _
            vbOkCancel, "CRISTA IT")
    If intAnswer = vbOk Then

    set objShell = wscript.CreateObject("wscript.shell")


    Else

    End If
    End If

    Thursday, May 28, 2015 7:05 PM

Answers

  • You would do better if you posted readable code:

    Set objSysInfo = CreateObject("Microsoft.Update.SystemInfo")
    
    If objSysInfo.RebootRequired Then
         If vbOk=Msgbox("A Reboot is pending, Press ""OK"" to reboot now or ""Cancel"" to reboot later", vbOkCancel, "CRISTA IT") Then
            ' Use WMI to reboot
         End If
    End If



    \_(ツ)_/


    • Edited by jrv Thursday, May 28, 2015 7:41 PM
    • Marked as answer by joengelhart Thursday, May 28, 2015 8:24 PM
    Thursday, May 28, 2015 7:41 PM
  • There is a comment in jrv's code to give you a hint that you need to put code in there.


    ' Use WMI to reboot
    

    For the script to reboot the computer, you will have to put the code in there that does a reboot. WMI is one way of doing it.

    Before you ask what the code is:

    http://www.google.com/search?q=reboot+computer+vbscript+wmi

    This should give you literally hundreds of examples.


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by joengelhart Thursday, May 28, 2015 8:24 PM
    Thursday, May 28, 2015 8:20 PM
    Moderator

All replies