When installing the required hotfix for Configuration Manager 2007 R3 you are probably faced with the challenge that you need to install more the one SCCM client hotfix. Installing them in the normal way would require three packages, programs and advertisements which need to be installed.

I wrote a script which will install all hotfixes placed in the same folder as the script I found a great example somewhere on how to write a MIF file which I cannot find again, sorry for not giving you credit for it.

The script will also create the .MIF file needed for Configuration Manager 2007 client to report back succeeded as the Configuration Manager Client hotfixes restarts the client service which makes the advertisement report back “Unexpected reboot”.

*****2011-08-23 – Updated with a new version of the script with improved error control******

Steps to implement the script:

  1. Create a collection to which you will advertise the Client Hotfixes, for instance use a query for all clients not having the latest version, in this example version 4.00.6487.2157.
    Example Query:select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.ClientVersion != “4.00.6487.2157″
  2. Download the sccm client hotfix script from here:http://ccmexec.com/wp-content/uploads/2011/08/updates11.vbs.txt
    It is also posted in the bottom of this page.
  3. Create a package with the script in the source files together with the client hotfixes you would like to install.
    SCCMhotfixes3
  4. For the MIF file to work the package name, version and publisher entered in the script must match the values for the package in SCCM. Change the following lines in the script to match it.
    Call SMSWriteStatusMIF(”Updates.MIF”,“Microsoft”,”SCCM Client Hotfixes”, “2007″,”The operation completed successfully.”,”true”)
    The picture below shows the reporting tab which is made up of the information for the package.
    SCCMhotfixes2
  5. Then create a program for the package according to the screenshot below, don’t forget to select the  “program restarts computer”. Which it will not but it will not report failure when the client service is restarted.  SCCMhotfixes1_red
  6. Then advertise the Program to the collection created in step 1.
    If there are many clients not having the latest version, test the script first on a couple of clients. And as always test and roll out these changes in a controlled way.

Script content:

'Version 1.1 - updated error control and reporting
'Option Explicit
Dim objfso, objShell
Dim folder, files, sFolder, folderidx, Iretval, return

Set objfso = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")

sFolder = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName)))

Set folder = objfso.GetFolder(sFolder)
Set files = folder.Files

For each folderIdx In files
If Ucase(Right(folderIdx.name,3)) = "MSP" then
wscript.echo "msiexec.exe /p " & sfolder & folderidx.name & " /q REINSTALL=ALL REINSTALLMODE=mous"
iretval=objShell.Run ("msiexec.exe /p " & sfolder & folderidx.name & " /q REINSTALL=ALL REINSTALLMODE=mous", 1, True)

If (iRetVal = 0) or (iRetVal = 3010) then

wscript.echo folderidx.name & " Success"
Else
wscript.echo folderidx.name & " Failed"
call SMSWriteStatusMIF("PNITNST.MIF","Microsoft","SCCM Client Hotfixes", "2007",FolderIDX.name & " reported error: " & iretval &" and failed to install","fail")
wscript.quit
End If
End If
Next

call SMSWriteStatusMIF("PNITNST.MIF","Microsoft","SCCM Client Hotfixes", "2007","The operation completed successfully.","true")

Sub SMSWriteStatusMIF(FileName,Manufacturer, Product, Version, Description, bSuccess)
' Writing a status MIF for SWDist to return a success or a failure to execute
' Product is the name of the Script and MIF file.
' Description is the status message
' bSuccess is True/False of success

Const ForWriting = 2
Dim mifFile
Dim WinDir

Set FileSys = CreateObject("Scripting.FileSystemObject")
WinDir = objShell.ExpandEnvironmentStrings("%WINDIR%")
Set mifFile = FileSys.CreateTextFile(WinDir & "\" & FileName , ForWriting)

With mifFile
.Writeline ("START COMPONENT")
.Writeline ("NAME = ""WORKSTATION""")
.Writeline (" START GROUP")
.Writeline (" NAME = ""ComponentID""")
.Writeline (" ID = 1")
.Writeline (" CLASS = ""DMTF|ComponentID|1.0""")

.Writeline (" START ATTRIBUTE")
.Writeline (" NAME = ""Manufacturer""")
.Writeline (" ID = 1")
.Writeline (" ACCESS = READ-ONLY")
.Writeline (" STORAGE = SPECIFIC")
.Writeline (" TYPE = STRING(64)")
.Writeline (" VALUE = """ & Manufacturer & """")
.Writeline (" END ATTRIBUTE")

.Writeline (" START ATTRIBUTE")
.Writeline (" NAME = ""Product""")
.Writeline (" ID = 2")
.Writeline (" ACCESS = READ-ONLY")
.Writeline (" STORAGE = SPECIFIC")
.Writeline (" TYPE = STRING(64)")
.Writeline (" VALUE = """ & Product & """")
.Writeline (" END ATTRIBUTE")

.Writeline (" START ATTRIBUTE")
.Writeline (" NAME = ""Version""")
.Writeline (" ID = 3")
.Writeline (" ACCESS = READ-ONLY")
.Writeline (" STORAGE = SPECIFIC")
.Writeline (" TYPE = STRING(64)")
.Writeline (" VALUE = """ & Version & """")
.Writeline (" END ATTRIBUTE")

.Writeline (" START ATTRIBUTE")
.Writeline (" NAME = ""Locale""")
.Writeline (" ID = 4")
.Writeline (" ACCESS = READ-ONLY")
.Writeline (" STORAGE = SPECIFIC")
.Writeline (" TYPE = STRING(16)")
.Writeline (" VALUE = ""ENU""")
.Writeline (" END ATTRIBUTE")

.Writeline (" START ATTRIBUTE")
.Writeline (" NAME = ""Serial Number""")
.Writeline (" ID = 5")
.Writeline (" ACCESS = READ-ONLY")
.Writeline (" STORAGE = SPECIFIC")
.Writeline (" TYPE = STRING(64)")
.Writeline (" VALUE = ""NIL""")
.Writeline (" END ATTRIBUTE")

.Writeline (" START ATTRIBUTE")
.Writeline (" NAME = ""Installation""")
.Writeline (" ID = 6")
.Writeline (" ACCESS = READ-ONLY")
.Writeline (" STORAGE = SPECIFIC")
.Writeline (" TYPE = STRING(64)")
.Writeline (" VALUE = ""DateTime""")
.Writeline (" END ATTRIBUTE")
.Writeline (" END GROUP")

.Writeline (" START GROUP")
.Writeline (" NAME = ""InstallStatus""")
.Writeline (" ID = 2")
.Writeline (" CLASS = ""MICROSOFT|JOBSTATUS|1.0""")
.Writeline (" START ATTRIBUTE")
.Writeline (" NAME = ""Status""")
.Writeline (" ID = 1")
.Writeline (" ACCESS = READ-ONLY")
.Writeline (" STORAGE = SPECIFIC")
.Writeline (" TYPE = STRING(32)")

' Pass or fail this status mif?
If bSuccess = "true" then
.Writeline (" VALUE = ""Success""")
else
.Writeline (" VALUE = ""Failed""")
End if

.Writeline (" END ATTRIBUTE")
.Writeline (" START ATTRIBUTE")
.Writeline (" NAME = ""Description""")
.Writeline (" ID = 2")
.Writeline (" ACCESS = READ-ONLY")
.Writeline (" STORAGE = SPECIFIC")
.Writeline (" TYPE = STRING(256)")
.Writeline (" VALUE = """ & Description & """")
.Writeline (" END ATTRIBUTE")
.Writeline (" END GROUP")
.Writeline ("END COMPONENT")
End With

mifFile.Close
Set mifFile = Nothing
End Sub
'Package Properties