Software Update – Pending Reboot Notification Based on OS Language (Updated Script)

*******************

03-02-2012

Updated scripts;

Now the script will use the windows updates icon(detect which icon to use  for  WinXP, 2003, Win 7 and 2008) in the systray and allow users to reboot from a onclick function and Show has traytip each 15 mins. Moreover, It will also detect the OS language (in this case French and English)  and use it for the notification.

Also, if you’re using the hta script (you must uncomment the ligne,   ;ShellExecuteWait(@ScriptDir & “\PromptReboot.hta”) in the autoit script) , this will allow you to configure a maximum number times users can postpone the reboot, countdown for automatic reboot( changes must be done in the CloseWindow sub).

*******************

Recently, one of my client asked me to move their patch management process from WSUS to SCCM and that for taking advantage of the reporting, distribution of patches in a multisite environment, etc. But here’s some limitations that I’ve encountered.

First, I can’t either use Maintenance Windows or force reboot on the majority of the workstation. Simply because it’s an 24/7 production environment and the user must be able to determine the proper time for the reboot … even if this is not a good practice.

Then, the notifications should be Display in the language of the OS even if the agent is Sccm English.


So, here the solution I’ve came up with… maybe you will find it usefull if you’re facing a situation like this.

Basicly, I used Autoit and HTA Edit, to create a script which will detect if there is some pending reboot due to a software update deployment. And if this is the case, it will notify the user. A icon will be display in the systray and will notify the user each 10 minutes (if you want to change the value, change the sleep in the autoit Script) and the hta application will ask the user for a reboot.

1- Hide notification for collections containing all the target workstations by using the following script;

http://scug.dk/blogs/configurationmanager/archive/2010/02/19/hide-and-show-software-update-notifications.aspx

thanks to Kent Agerlund for this

2- Create a collection for device in pending reboot due to software update (you maybe need to exclude some collections, ex, srv collection or create an empty collection which is restricted to query the collection created in step 1)

http://joshuasmueller.wordpress.com/2010/05/04/reboot-pending/

or

http://myitforum.com/cs2/blogs/idany/archive/2008/12/04/collections-based-on-software-updates-deployment-status-in-configuration-manager.aspx

3- Then create your deployment template, which should be configure to supress the reboot and hide the notification to the user.

4- Use AutoIt to compile the following script, create a software deployment and advertise it to the appropriate collection with the rerun settings you needs.

  • Make sure to change the ICO file path
  • note, if you compile the script in 32-bit version and execute on a 64-bit position, you must copy the DLL to the directory the script, otherwise it can not find the icon

    If needed, install autoit from; http://www.autoitscript.com/site/autoit/downloads/

Download Script(RebootNotification)

******************************************************************

; AutoIt Version: 3.0

; Language:       English and French

; Platform:       Win9x/NT/2000/XP/Win7

; Author:         Tom Watson

; Modify :                        SBro

; Script Function:

;   Check If there is a pending reboot since a updates deployment

;   Displays Systray Notification Based on OS language

;

#include <Constants.au3>

#NoTrayIcon

Opt(“TrayOnEventMode”, 1)

Opt(“TrayMenuMode”, 1) ; Default tray menu items (Script Paused/Exit) will not be shown.

AutoItSetOption ( “TrayIconHide” , 1 )

$aPList = ProcessList(@ScriptName)

For $i = 1 To $aPList[0][0]

If $aPList[$i][1] <> @AutoItPID Then Exit

Next

Select

Case StringInStr(“WIN_7,WIN_2008”, @OSVersion)

TraySetIcon(“wucltux.dll”, 1)

TraySetState(1)

Break(0)

Case StringInStr(“WIN_XP,WIN_2003”, @OSVersion)

TraySetIcon(“wucltui.dll”, 4)

TraySetState(1)

Break(0)

EndSelect

For $i= 1 to 5 ; Number of subkey SU who is actually Pending for Reboot

$var = RegEnumKey(“HKEY_LOCAL_MACHINE\SOFTWARE\microsoft\SMS\Mobile Client\Updates Management\Handler\UpdatesRebootStatus”, $i)

If @error <> 0 then ExitLoop

Select

Case StringInStr(“040c,0c0c”, @OSLang) ; French OS

TraySetToolTip (“VOUS DEVEZ REDÉMARRER VOTRE PC”)

TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, “MsgFrench”)

While 1 = 1

TrayTip(“Service Technique”, “Des mises à jours critiques et de sécurités ont été installées sur votre Pc. Sauvegardez vos données et redémarrer dès que possible.”, 12, 1)

Sleep (20000)

TrayTip(“”,””,0)

;ShellExecute(@ScriptDir & “\PromptReboot-fr.hta”)

Sleep(900000)

WEnd

Case StringInStr(“0409,0809,0c09,1009,1409,1809,1c09,2009,2409,2809,2c09,3009,3409”, @OSLang) ; US-EN OS

TraySetToolTip (“PLEASE RESTART YOUR SYSTEM”)

TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, “MsgEnglish”)

While 1 = 1

TrayTip(“Technical Support “,”Critical and security updates have been installed on your system. Please save your work and restart your system as soon as possible.”, 12, 1)

Sleep (20000)

TrayTip(“”,””,0)

;ShellExecuteWait(@ScriptDir & “\PromptReboot.hta”)

Sleep(900000)

WEnd

EndSelect

Next

Func MsgFrench()

Select

Case @TRAY_ID = $TRAY_EVENT_PRIMARYDOWN

$MsgBoxfr = MsgBox(260, “Question”, “Voulez-Vous Redémarrer Votre Ordinateur Maintenant”)

If $MsgBoxfr = 6 Then

Shutdown (6, “Software update iniated shutdown” )

EndIf

EndSelect

EndFunc

Func MsgEnglish()

Select

Case @TRAY_ID = $TRAY_EVENT_PRIMARYDOWN

$MsgBoxEn = MsgBox(260, “Question”, “Would You Like To Restart Your Computer Now”)

If $MsgBoxEn = 6 Then

Shutdown (6, “Software update iniated shutdown” )

EndIf

EndSelect

EndFunc

******************************************************************

Also, here’s where i found the basic idea for the script;

http://myitforum.com/cs2/blogs/tom_watson/archive/2010/01/04/reboot-nag-using-autoit.aspx

5 – If needed, you can add the following HTA script to configure a maximum number times users can postpone the reboot, countdown for automatic reboot( changes must be done in the CloseWindow sub). Also, the hta script must be in the same directory as the autoit Script and note that the max postpone and countdown option as been disabled in the script.

Download Script (PromptReboot)

******************************************************************

promptreboot-fr.hta

Use the same as the promptreboot.hta, but change the notification.

Advertisements

4 thoughts on “Software Update – Pending Reboot Notification Based on OS Language (Updated Script)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s