15 May 2012

Adobe Flash Installation Script

This script will install both the x86 and x64 versions of Flash Player 11.x. It uninstalls all previous versions of Flash first. Flash 11.x is then installed, and finally the mms.cfg file is copied over to set Flash to automatically update. Both x86 and x64 versions of Flash are installed on 64-bit machines because those machines contain both x86 and x64 browsers.

Here is a link to download the script and here is a link for the mms.cfg file


 '*******************************************************************************  
 '     Program: InstallFlash.vbs  
 '      Author: Mick Pletcher  
 '        Date: 11 April 2012  
 '    Modified:  
 '  
 '   Publisher: Adobe  
 '     Program: Flash  
 '     Version: 11.x  
 ' Description: Adobe Flash Installation  
 '                 1) Define Relative Installation Path  
 '                 2) Determine Architecture  
 '                 3) Create Logs Folder  
 '                 4) Uninstall all old versions of Flash  
 '                 5) Install Flash  
 '                 6) Copy MMS File  
 '                 6) Initiate SMS Hardware Inventory  
 '                 7) Cleanup Global Variables  
 '                 8) Exit Installation  
 '*******************************************************************************  
 Option Explicit  

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

 REM Define Global Variables  
 DIM Architecture : Set Architecture = Nothing  
 DIM LogFolder    : LogFolder    = TempFolder & LogFolderName & "\"  
 DIM RelativePath : Set RelativePath = Nothing  
 REM Define Relative Installation Path  

 DefineRelativePath()  
 REM Determine Architecture  
 DetermineArchitecture()  
 REM Create Logs Folder  
 CreateLogFolder()  
 REM Uninstall Old Version of Flash  
 UninstallOldFlash()  
 REM Install Flash  
 InstallFlash()  
 REM Copy MMS File  
 CopyMMS()  
 REM Initiate SMS Hardware Inventory  
 InitiateSMSHardwareInventory()  
 REM Cleanup Global Variables  
 GlobalVariableCleanup()  

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

 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 DetermineArchitecture()  

      REM Define Local Objects  
      DIM WshShell : Set WshShell = CreateObject("WScript.Shell")  

      REM Define Local Variables  
      DIM OsType : OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")  

      If OsType = "x86" then  
           Architecture = "x86"  
      elseif OsType = "AMD64" then  
           Architecture = "x64"  
      end if  

      REM Cleanup Local Variables
      Set WshShell = Nothing
      Set OSType   = Nothing

 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 Objects & Variables  
      Set FSO = Nothing  

 End Sub  

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

 Sub UninstallOldFlash()  

      REM Define Local Objects  
      DIM FSO    : SET FSO    = CreateObject("Scripting.FileSystemObject")  
      DIM oShell : SET oShell = CreateObject("Wscript.Shell")  

      REM Define Local Variables  
      DIM oAPPDATA     : oAPPDATA     = oShell.ExpandEnvironmentStrings("%APPDATA%")  
      DIM Parameters   : Parameters   = Chr(32) & "-uninstall activex"  
      DIM Uninstallx86 : Uninstallx86 = RelativePath & "uninstall_flash_player_32bit.exe" & Parameters  
      DIM Uninstallx64 : Uninstallx64 = RelativePath & "uninstall_flash_player_64bit.exe" & Parameters  

      If Architecture = "x86" then  
           oShell.Run Uninstallx86, 1, True  
      Else  
           oShell.Run Uninstallx64, 1, True  
      End If  
      If FSO.FolderExists("C:\Windows\system32\Macromed\Flash\") then  
           FSO.DeleteFile "C:\Windows\system32\Macromed\Flash\*.*", True  
           FSO.DeleteFolder "C:\Windows\system32\Macromed\Flash", True  
      End If  
      If FSO.FolderExists("C:\Windows\SysWOW64\Macromed\Flash\") then  
           FSO.DeleteFile("C:\Windows\SysWOW64\Macromed\Flash\*.*")  
           FSO.DeleteFolder "C:\Windows\system32\Macromed\Flash", True  
      End If  
      If FSO.FolderExists(oAPPDATA & "\Adobe\Flash Player\") then  
           FSO.DeleteFile(oAPPDATA & "\Adobe\Flash Player\*.*")  
           FSO.DeleteFolder oAPPDATA & "\Adobe\Flash Player", True  
      End If  
      If FSO.FolderExists(oAPPDATA & "\Macromedia\Flash Player\") then  
           FSO.DeleteFile(oAPPDATA & "\Macromedia\Flash Player\*.*")  
           FSO.DeleteFolder oAPPDATA & "\Macromedia\Flash Player", True  
      End If  

      REM Cleanup Local Objects & Variables  
      Set FSO          = Nothing  
      Set oShell       = Nothing  
      Set Parameters   = Nothing  
      Set Uninstallx86 = Nothing  
      Set Uninstallx64 = Nothing  

 End Sub  

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

 Sub InstallFlash()  

      REM Define Local Objects  
      DIM oShell : SET oShell = CreateObject("Wscript.Shell")  

      REM Define Local Variables  
      DIM Filex86    : Filex86    = Chr(32) & RelativePath & "install_flash_player_11_active_x_32bit.msi"  
      DIM Filex64    : Filex64    = Chr(32) & RelativePath & "install_flash_player_11_active_x_64bit.msi"  
      DIM LogFilex86 : LogFilex86 = Chr(32) & "/lvx" & Chr(32) & LogFolder & "Flash11x86.log"  
      DIM LogFilex64 : LogFilex64 = Chr(32) & "/lvx" & Chr(32) & LogFolder & "Flash11x64.log"  
      DIM Parameters : Parameters = Chr(32) & "/qb- /norestart"  
      DIM Install32  : Install32  = "msiexec.exe /i" & Filex86 & LogFilex86 & Parameters  
      DIM Install64  : Install64  = "msiexec.exe /i" & Filex64 & LogFilex64 & Parameters  

      oShell.Run Install32, 1, True  
      If Architecture = "x64" Then  
           oShell.Run Install64, 1, True  
      End If  

      REM Cleanup Local Variables  
      Set Filex86    = Nothing  
      Set Filex64    = Nothing  
      Set LogFilex86 = Nothing  
      Set LogFilex64 = Nothing  
      Set oShell     = Nothing  
      Set Parameters = Nothing  
      Set Install32  = Nothing  
      Set Install64  = Nothing  

 End Sub  

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

 Sub CopyMMS()  

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

      If Architecture = "x86" then  
           If FSO.FileExists("C:\Windows\system32\Macromed\Flash") then  
                FSO.DeleteFile "C:\Windows\system32\Macromed\Flash\mms.cfg", True  
           End If  
           FSO.CopyFile RelativePath & "mms.cfg", "C:\Windows\system32\Macromed\Flash\", True  
      Else  
           If FSO.FileExists("C:\Windows\SysWow64\Macromed\Flash") then  
                FSO.DeleteFile "C:\Windows\SysWow64\Macromed\Flash\mms.cfg", True  
           End If  
           FSO.CopyFile RelativePath & "mms.cfg", "C:\Windows\SysWow64\Macromed\Flash\", True  
      End If  

      REM Cleanup Local Variables
      Set FSO = Nothing

 End Sub  

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

 Sub InitiateSMSHardwareInventory()  

      On Error Resume Next  

      REM Define Local Objects
      DIM oCPAppletMgr   : Set oCPAppletMgr   = CreateObject("CPApplet.CPAppletMgr")  
      DIM oClientAction  : Set oClientAction  = Nothing  
      DIM oClientActions : Set oClientActions = oCPAppletMgr.GetClientActions()  

      For Each oClientAction In oClientActions  
           If oClientAction.Name = "Hardware Inventory Collection Cycle" Then  
                oClientAction.PerformAction  
           End If  
      Next  

      REM Cleanup Local Objects
      Set oCPAppletMgr   = Nothing
      Set oClientAction  = Nothing  
      Set oClientActions = Nothing

 End Sub  

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

 Sub GlobalVariableCleanup()  

      Set Architecture = Nothing  
      Set LogFolder    = Nothing  
      Set RelativePath = Nothing  

 End Sub  

10 comments:

  1. Great..
    The only small improvement that I could see is that you may need one more section to check if IE is open and close it before you start the uninstall process..
    Otherwise very through.. :)

    ReplyDelete
    Replies
    1. True. The reason I did not include that was because I deployed this package through SMS and set it to only run when no user was logged on.

      Delete
  2. I'm planning on installing Adobe Flash Player 11.4.402.265. Did Adobe do away with having a separate 32/64 installation files? I am only seeing one.

    ReplyDelete
    Replies
    1. Good question. I am not for sure. The firm I work for only uses Windows 7 64-bit.

      Delete
    2. The uninstaller at http://helpx.adobe.com/flash-player/kb/uninstall-flash-player-windows.html runs on both 32-bit and 64-bit and uses the "- force" option by default.

      It logs to C:\Windows\System32\Macromed\Flash\FlashInstall.log, so you can see what it has done.

      Delete
  3. I, alas, don't know any VBS :-(

    I'm trying to understand the LogFolder and RelativePath variables. I'm guessing you run the script with 'cscript InstallFlash.vbs Path\To\Files\flash.msi' and extract the path. Is that correct?

    How would I use your script to install from \\domain\dfsroot\setups\flash\VersionNumber\VersionNumber.msi and log to \\domain\dfsroot\_Public\_Logs\Flash_Install_MachineName.log? Ideally with uninstall_flash_player.exe in from \\domain\dfsroot\setups\flash\ so I don't have to copy it into each Flash folder. How would I add the plugin installers?

    Thank you for sharing your work. May I post it to Experts Exchange as a basis for the script I want?

    ReplyDelete
    Replies
    1. The way I wrote the script allows you to place the script inside the same directory as the flash MSI file resides and it uses the relative path (Current location) to run the msi. I have it written so that it will install both the 32 and 64 bit apps, as each is needed on a 64-bit machine. It only runs the 32 bit on a 32 bit machine.

      Delete
    2. And it appends to Flash11x##.log in c:\temp\AdobeFlash\?

      I keep my logs on a server so I can grep them for errors. I also like to have the script and the source folders separate for general housekeeping. I will see if I can find someone to make a script that follows my normal practices.

      Is it OK if I use your script as a starting place for mine? What attribution do you want?

      *Thank You*

      Delete
  4. Asking questions are genuinely nice thing if you are not understanding anything completely, but this post gives fastidious understanding even.


    Also visit my page: Winders by Wolf (vandesteene.weebly.com)

    ReplyDelete
  5. Fantastic goods from you, man. I have ber in mind your stuff prior to annd you're just
    extremely great. I actually like what you have received here, certainly like what you're stating and
    the way in which inn which youu assert it. You make it entertaining and you till care foor to
    stay it sensible. I can not wait to read far more from
    you. This is really a terrific site.

    Check out my web blog more hints

    ReplyDelete