Menu
CCMEXEC.COM – Enterprise Mobility
  • Home
  • General
  • Configuration Manager
  • Windows 10
  • Intune
  • GitHub
  • Windows 11
  • About the author
CCMEXEC.COM – Enterprise Mobility

Installing multiple Windows 7 hotfixes(.msu) with SCCM

Posted on February 10, 2012 by Jörgen Nilsson

Sometimes you want to deploy more that one Windows 7 hotfix with Configuration Manager. The hotfixes for Windows 7 is .MSU files and are installed using Wusa.exe.
If you wan to make the hotfix installation silent you simply add /quiet /norestart on the command line aswell.

Example command line: Wusa.exe c:\temp\Windows6.1-KB982018-v3-x64.msu /quiet /norestart

To simplify the installation I have made a small script the will parse all the files in the same directory as the script and install all files which ends with .MSU automatically. It can both be used to distribute the hotfixes using software distribution or in a Task Sequence so you can install the updates during OSD.

multiple_msu
To use it simply save the script in the same folder as you Windows 7 hotfixes you want to deploy and then create a package and program with the folder as package source and the command line configured as below.

multiple_msu1

I strongly recommend that you allow configuration manager to restart the computer, otherwise the user can be prompted by the Windows Update agent to restart within 10  minutes.

If you need to troubleshoot it run it with allow user to interact, then you will see the updates being displayed in a command prompt.

Installmsu.vbs script:

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)) = "MSU" then
wscript.echo "wusa.exe " & sfolder & folderidx.name & " /quiet /norestart"
iretval=objShell.Run ("wusa.exe " & sfolder & folderidx.name & " /quiet /norestart", 1, True)
If (iRetVal = 0) or (iRetVal = 3010) then
wscript.echo folderidx.name & " Success"
Else
wscript.echo folderidx.name & " Failed"
wscript.quit(1)
End If
End If
Next

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)) = "MSU" then

wscript.echo "wusa.exe " & sfolder & folderidx.name & " /quiet /norestart"

iretval=objShell.Run ("wusa.exe " & sfolder & folderidx.name & " /quiet /norestart", 1, True)

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

wscript.echo folderidx.name & " Success"

Else

wscript.echo folderidx.name & " Failed"

wscript.quit(1)

End If

End If

Next

18 thoughts on “Installing multiple Windows 7 hotfixes(.msu) with SCCM”

  1. Modified version of MSU Installer doesnt need use of configuration manager says:
    March 4, 2012 at 5:59 pm

    ‘https://ccmexec.com/2012/02/installing-multiple-windows-7-hotfixes-msu-with-sccm/
    ‘http://www.insidethe.com/blog/2009/12/how-to-launch-a-wsh-vbscript-as-administrator-in-windows-7-and-vista/

    mytitle=”MSU Installer”
    mybuttons=65 ‘ vbOKCancel + vbInformation

    If WScript.Arguments.Named.Exists(“elevated”) = False Then

    ‘Launch the script again as administrator

    CreateObject(“Shell.Application”).ShellExecute “wscript.exe”, “””” & WScript.ScriptFullName & “”” /elevated”, “”, “runas”, 1

    WScript.Quit

    Else

    ‘Change the working directory from the system32 folder back to the script’s folder.

    Set oShell = CreateObject(“WScript.Shell”)

    oShell.CurrentDirectory = CreateObject(“Scripting.FileSystemObject”).GetParentFolderName(WScript.ScriptFullName)

    MsgBox “Now running with elevated permissions”,0,mytitle

    End If

    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

    something=0 ‘ there is nothing to do

    For each folderIdx In files

    If Ucase(Right(folderIdx.name,3)) = “MSU” then

    something=1 ‘ there is something to do.

    wscript.echo “wusa.exe ” & sfolder & folderidx.name & ” /quiet /norestart”
    ‘wscript.echo “wusa.exe ” & sfolder & folderidx.name

    iretval=objShell.Run (“wusa.exe ” & sfolder & folderidx.name & ” /quiet /norestart”, 1, True)
    ‘iretval=objShell.Run (“wusa.exe ” & sfolder & folderidx.name, 1, True)

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

    ‘wscript.echo folderidx.name & ” Success”
    myprompt=folderidx.name & ” Success ” & “[” & iRetVal & “]”

    Else

    ‘wscript.echo folderidx.name & ” Failed”
    myprompt=folderidx.name & ” Failed ” & “[” & iRetVal & “]”

    End If

    devam=MsgBox(myprompt,mybuttons,mytitle)
    If (devam = 2) or (devam = 3) or (devam = 7) Then
    ‘Cancel/Abort/No was clicked
    wscript.quit(1)
    End If

    End If

    Next

    If (something = 0) Then
    MsgBox “Nothing to do.”,64,mytitle
    Else
    MsgBox “Done.”,64,mytitle
    restartla=MsgBox(“Close all programs and press Yes to restart or No to continue.”,36,mytitle)
    If (restartla = 6) Then
    Set WSHShell = WScript.CreateObject(“WScript.Shell”)
    WshShell.Run “%SYSTEMROOT%\system32\shutdown.exe /r /t 0”
    End If
    End If

    Reply
  2. Pingback: Hotfix KB2525332 - Delay when Offline Files and Folder Redirection are Used
  3. Dheeraj says:
    October 31, 2012 at 8:26 am

    Thanks works like a charm 🙂

    Reply
  4. benoit says:
    November 22, 2012 at 11:25 am

    Hi,
    I have one question regarding hotfixes. How do you detect if the hotfix was correctly installed? With programs, I can use queries and look in the “Add/Remove Programs” attribute class. But hotfixes are not in Add/Remove Programs… Do you know where the information is stored ?
    Thanks,
    Benoit

    Reply
  5. Pingback: Install Windows hotfixes (.MSU) during OS deployment using MDT/SCCM2012. | System Center Guru
  6. ta says:
    December 20, 2013 at 9:50 pm

    I am new to SCCM, scripts, everything. I need to deploy a list of .msu hotfixes to our company, and want to try your script. I feel really stupid asking, but do I need to alter it in any way (for example the names of the .msu’s, the server name, anything?)…

    Reply
    1. Jörgen Nilsson says:
      January 10, 2014 at 2:55 pm

      Hi,
      No there is nothing you need to alter..

      /Jörgen

      Reply
  7. Arindam says:
    July 13, 2014 at 7:17 am

    Hi

    May be I am doing it wrong… I copied your script from “Dim objfso, objShell” till the word “Next”, pasted it on a notepad and changed the name to Installmsu.vbs…. I kept all the .msu (I am trying to install IE 10 prerequisites) in one folder along with the Installmsu.vbs..Then I am using it with the command you mentioned above cscript Installmsu.vbs in the SCCM command line…but everytime it ends up with error code 1 in execmgr and installation fails. I tried it separately on my machine using just the command prompt, it fails… FYI, I am using download and run in my SCCM adverts. Please tell me what I am doing wrong…!!
    Thanks in Advance…

    Reply
    1. JD says:
      September 12, 2019 at 12:43 pm

      Same problem here. Did you find the solution?

      Reply
  8. Jeff says:
    September 16, 2014 at 5:50 pm

    This script worked perfectly! Thank you so much for posting it!!!

    Reply
  9. Rafeeq says:
    May 12, 2015 at 9:11 pm

    Worked Perfectly 🙂 Thanks man!!

    Reply
  10. Soumya Bhattacharyya says:
    November 2, 2015 at 7:32 pm

    Thank you for the post. Only one question, why are you quitting the script when any .msu file installation is getting failed ? Removed the line :
    wscript.quit(1)
    and it’s working great. Thanks again.

    Reply
    1. Jörgen Nilsson says:
      November 2, 2015 at 8:26 pm

      Hi,
      Because I wan’t to know if it fails so I can act on it. If you deploy updates where you know some will fail, just remove it as you just wrote.
      /Jörgen

      Reply
  11. sanjeev says:
    June 21, 2016 at 6:36 pm

    Not work for me

    Reply
  12. Quang Trieu Minh says:
    June 25, 2016 at 3:23 pm

    Hi Jorgen Nilssion

    I have executed the script on client to was successful for 30 minitues. However, I deployed it to Client by package which was built on SCCM server while it still was running and no stopping as bellow command line in Process :

    “c:\Windows\System32\wusa.exe” “C:\windows\ccmcache\k\Windows6.1-KB3161949-x64.msu /quiet /norestart”

    Reply
  13. Quang Trieu Minh says:
    June 25, 2016 at 3:25 pm

    Hi Jorgen Nilssion
    I have executed the script on client to was successful for 30 minitues. However, I deployed it to Client by package which was built on SCCM server while it still was running and no stopping as bellow command line in Process :
    “c:\Windows\System32\wusa.exe” “C:\windows\ccmcache\k\Windows6.1-KB3161949-x64.msu /quiet /norestart”

    Please help me to solve the issue.

    Thank for your support.
    Quang Trieu

    Reply
  14. Sunil KC says:
    July 20, 2016 at 10:24 am

    In the Deplymen type select “Script” installation and just run the cmd wusa.exe “Windows6.1-KB3161949-x64.msu” /quiet /norestart

    In the “User Experience” set it for “Configuration Manager client will force a mandatory device restart”.

    Even though you have used /norestart the SCCM will still wait for reboot prompt.

    Reply
  15. Guillermo Vélez says:
    August 1, 2016 at 5:03 pm

    The problem that I had with this script is that when there is one previous KB already installed, this fails and the others on the folder will remain uninstalled. However by making some changes on the script from Daniel Classon, http://www.danielclasson.com/powershell-install-hotfixes-only-if-they-are-not-installed/, I got the problem solved.

    $source = “.” #Source folder
    $KBArrayList = @(“KB976373″,”KB980295”, “KB2481614”, “KB2494172”, “KB2736878”) #Patches that you need to install.
    foreach ($KB in $KBArrayList) {
    if ((Get-Hotfix -Id $KB -ea SilentlyContinue) -eq $Null) {
    Start-Process -FilePath “wusa.exe” -ArgumentList “$source\$KB.msu /quiet /norestart” -Wait
    }
    }

    This could be improved by importing a comma separated value file to create the array. Who would be the brave?…. 🙂

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

My name is Jörgen Nilsson and I work as a Senior Consultant at Onevinn in Malmö, Sweden. This is my blog where I will share tips and stuff for my own and everyone elses use on Enterprise Mobility and Windows related topics.
All code is provided "AS-IS" with no warranties.

Tweets by ccmexec

Recent Posts

  • Windows Servicing, Personal Teams and Success.cmd
  • Windows MDM Security Baseline – Settings Catalog
  • Configuring MS Edge Security Baseline v107 using Settings Catalog
  • Configuring Desktop App Installer using CSP and script?!
  • Customizing Taskbar and Start in Windows 11 22h2 with PowerShell

©2023 CCMEXEC.COM – Enterprise Mobility | WordPress Theme by Superb Themes
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.Accept Reject Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT