In my quest to find the best method(s) for detecting if a system reboot is required, I came across the RebootNeeded script at www.wsus.nl.
This function determines if a reboot is needed due installation of patches.
Example
Code
'************* Example ************* If RebootNeeded() Then Wscript.Echo "A reboot is needed to complete the installation."Else Wscript.Echo "No reboot required!"End If
'****************************************************************************' Function RebootNeeded()'' Checks if a reboot is needed.'****************************************************************************Function RebootNeeded()
On Error Resume Next Dim objSystemInfo Dim flgRebootNeeded flgRebootNeeded = False Set objSystemInfo = WScript.CreateObject("Microsoft.Update.SystemInfo") If Err.Number <> 0 Then Wscript.Echo "Error creating [Microsoft.Update.SystemInfo] object 0x" & Right("0000000" & Hex(Err.Number), 8) & ": " & Err.Description Err.Clear End If flgRebootNeeded = objSystemInfo.rebootrequired Set objSystemInfo = Nothing
RebootNeeded = flgRebootNeeded
End Function
It is probably not evident from the code in the sample above, but the script must be run from the local system to determine if it requires a reboot for a patch to become fully installed.
There is another script (PatchesInstalling) over at the www.wsus.nl site which will determine if a patch installation is in progress.
Published Monday, May 22, 2006 1:09 AM by dthomson
No Comments