28 June 2013

Apply all Microsoft Office Updates within a folder

Here is a script that will install all Microsoft Office updates within the same folder. It queries the folder for all of the filenames and then runs installs the updates.

You can download the script from here.

 '*******************************************************************************  
 '   Author: Mick Pletcher  
 '    Date: 28 June 2013  
 '  Modified:  
 '  
 ' Description: This will install all office updates residing in the same folder as this  
 '                 script.  
 '                 1) Define the relative installation path  
 '                 2) Create the Log Folder  
 '                 3) Read list of Updates into Array  
 '                 4) Install updates  
 '                 5) Cleanup Global Memory  
 '*******************************************************************************  

 Option Explicit  

 REM Define Constants  
 CONST TempFolder    = "c:\temp\"  
 CONST LogFolderName = "OfficeUpdates"  

 REM Define Global Variables  
 DIM Count        : Count      = 1  
 DIM LogFolder    : LogFolder    = TempFolder & LogFolderName & "\"  
 DIM RelativePath : Set RelativePath = Nothing  
 ReDIM arrFiles(1)  

 REM Define the relative installation path  
 DefineRelativePath()  
 REM Create the Log Folder  
 CreateLogFolder()  
 REM Read list of Updates into Array  
 ReadUpdates()  
 REM Install Updates  
 InstallUpdates()  
 REM Cleanup Global Memory  
 GlobalMemoryCleanup()  

 '*******************************************************************************  
 '*******************************************************************************  

 Sub DefineRelativePath()  

      REM Get File Name with full relative path  
      RelativePath = WScript.ScriptFullName  
      REM Remove file name, leaving relative path only  
      RelativePath = Left(RelativePath, InStrRev(RelativePath, "\"))  

 End Sub  

 '*******************************************************************************  

 Sub CreateLogFolder()  

      REM Define Local Objects  
      DIM FSO : Set FSO = CreateObject("Scripting.FileSystemObject")  

      If NOT FSO.FolderExists(TempFolder) then  
           FSO.CreateFolder(TempFolder)  
      End If  
      If NOT FSO.FolderExists(LogFolder) then  
           FSO.CreateFolder(LogFolder)  
      End If  

      REM Cleanup Local Variables  
      Set FSO = Nothing  

 End Sub  

 '*******************************************************************************  

 Sub ReadUpdates()  

      REM Define Local Objects  
      DIM FSO : Set FSO = CreateObject("Scripting.FileSystemObject")  

      REM Define Local Variables  
      DIM Folder : Set Folder = FSO.GetFolder(RelativePath)  
      DIM Files  : Set files = Folder.Files  
      DIM File   : Set File  = Nothing  

      For each File in Files  
           If NOT File.Name = Wscript.ScriptName then  
                arrFiles(Count) = File.Name  
                Count = Count + 1  
                ReDim Preserve arrFiles(Count)  
           End If  
      Next  
      Count = Count - 1  

      REM Cleanup Local Memory  
      Set File   = Nothing  
      Set Files  = Nothing  
      Set Folder = Nothing  
      Set FSO    = Nothing  

 End Sub  

 '*******************************************************************************  

 Sub InstallUpdates()  

      REM Define Local Objects  
      DIM File     : Set File   = Nothing  
      DIM FSO      : Set FSO   = CreateObject("Scripting.FileSystemObject")  
      DIM i        : Set i    = Nothing  
      DIM oShell   : Set oShell  = CreateObject("Wscript.Shell")  
      DIM Switches : Set Switches = Nothing  

      For i = 1 to Count  
           File = Left(arrFiles(i),Len(arrFiles(i))-4)  
           Switches = Chr(32) & "/passive /norestart /log:" & LogFolder & File & ".log"  
           oShell.run arrFiles(i) & Switches, 1, True  
      Next  

      REM Cleanup Local Memory  
      Set File     = Nothing  
      Set FSO      = Nothing  
      Set i        = Nothing  
      Set oShell   = Nothing  
      Set Switches = Nothing  

 End Sub  

 '*******************************************************************************  

 Sub GlobalMemoryCleanup()  

      Set Count        = Nothing  
      Set LogFolder    = Nothing  
      Set RelativePath = Nothing  
      Erase arrFiles  

 End Sub  

Related Posts:

  • Replicate Permissioning Here is a script I have written that will replicate the permissions between two folders including all subfolders and file permissions. Execute the script and you will be prompted for the source and destination folders. It w… Read More
  • Deploying Windows Management Framework 4.0 This PowerShell script will install WMF 4.0. It will return an error if the installation fails. You can download the script from here. <# .Author Mick Pletcher .Date 29 July 2014 .SYNOPSIS … Read More
  • Uninstall All Printers Recently, we upgraded our print servers and needed to reinstall all of the printers. This script will uninstall all printers. I deployed this script out and had it run as the user and a GPO reinstalled the printer with the … Read More
  • List of Installed Updates This script will generate a clean list of Microsoft updates that were installed during a system build, making it drastically easier than having to parse through the log file. You open the powershell script up and update the… Read More
  • Deploying CMTrace CMTrace makes reading .log files much easier. Deploying it though can be somewhat tricky. I have written this PowerShell script that will install CMTrace and associates .log with the application. The association portion of … Read More

0 comments:

Post a Comment