caffrey Posted October 15, 2010 Posted October 15, 2010 I found a nice VBScript that installs java (checks versions, uninstalls old and installs latest) - works really well. So i took it upon myself to create / hack about with the script for adobe flash (currently the directX for IE) So does this look ok ? - Seems to run fine - ignore the environment variables (c:\flash) Its quick and dirty, not done any vb in years! Might seem overkill I guess, but it logs which machines have it installed - similar to the java one i found. Option Explicit Dim wshShell, fso, strLogFile, ts, strTempDir, strUnString, tsIn Dim CLSID, strDisplayName, strDisplayVersion Dim strPublisher, strUninstLine Dim search1, search2, search3 Dim strComputername, strCurrentVersion, strInstallMST Dim searchCurVer, CurVerFound, strLogPath, strInstallCMD, strInstallMSI, strInstallLog Dim flashversion '# Change this to match the current version. strCurrentVersion = "10.1.85.3" '#change this for log path strLogPath = "c:\flash\" '#change this for install path strInstallMSI = "c:\flash\install_flash_player_10_active_x.msi" Set wshShell = CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") strComputername = wshShell.ExpandEnvironmentStrings("%COMPUTERNAME%") strInstallLog = strLogPath & "Flash_Install_" & strComputername & ".log" strInstallCMD = "msiexec /I " & strInstallMSI & " /quiet" '#some other code PreFlight() strTempDir = wshShell.ExpandEnvironmentStrings("%TEMP%") Set tsIn = fso.OpenTextFile(strTempDir & "\uninstall.tmp", 1) Do While Not tsIn.AtEndOfStream strUninstLine = tsIn.ReadLine CLSID = Mid(strUninstLine, 73, 38) On Error Resume Next strDisplayName = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & CLSID & "\DisplayName") strPublisher = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & CLSID & "\Publisher") strDisplayVersion = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & CLSID & "\DisplayVersion") On Error Goto 0 'Search for presence of flash in DisplayName and Publisher search1 = Instr(1, strDisplayName, "Adobe Flash Player 10 ActiveX", 1) search2 = Instr(1, strPublisher, "Adobe Systems Incorporated", 1) search3 = Instr(1, strDisplayVersion, strCurrentVersion, 1) 'See if it is the current version searchCurVer = InStr(1, strDisplayVersion, strCurrentVersion, 1) 'If it is, Show that the current version is found If searchCurVer > 0 Then CurVerFound = True flashversion = strDisplayVersion ElseIf searchCurVer <> 0 Then CurVerFound = False End If Loop tsIn.Close() Set ts = fso.OpenTextFile(strInstallLog, 8, True) If CurVerFound = True Then ts.WriteLine Now() & " Flash - Current version, " & flashversion & " found - No Update Needed." ts.close WScript.Quit() ElseIf CurVerFound =false Then ts.writeline now() & " Flash Not Found, New Installation started" wshshell.run(strInstallCMD) ts.writeline now() & " " & strCurrentVersion & " Installed" ts.close WScript.quit() End If Sub PreFlight() '# Creates temp files containing extracts from registry 'Uninstall' keys. Dim wshShell, fso, sTemp Set wshShell = CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") sTemp = wshShell.ExpandEnvironmentStrings("%temp%") wshShell.Run "REGEDIT /E %temp%\registry.tmp HKEY_LOCAL_MACHINE\SOFTWARE\microsoft\windows\currentversion\uninstall", 0, True wshShell.Run "cmd /c type %temp%\registry.tmp | find /i ""{"" | find /i ""}]"" > %temp%\uninstall.tmp ", 0, True If Not fso.FileExists(sTemp & "\uninstall.tmp") Then ts.WriteLine Now() & " - No input - %temp%\uninstall.tmp Reg extract not created." ts.WriteLine String(120, "_") ts.WriteLine String(120, "¯") ts.Close WScript.Quit(1) End If End Sub
caffrey Posted October 19, 2010 Author Posted October 19, 2010 cleaned it up a lot, i reckon the reg key for flash won't change - so i slimmed the script down as much as i could still a bit rough ?. Option Explicit Dim wshShell, fso, strLogFile, ts, strTempDir Dim strDisplayName, strVersion Dim search, flashversion Dim strComputername, strCurrentVersion, strInstallMST Dim searchCurVer, CurVerFound, strLogPath, strInstallCMD, strInstallMSI, strInstallLog '# Change this to match the current version. strCurrentVersion = "10.1.85.3" '#change this for log path strLogPath = "c:\flash\" '#change this for install path strInstallMSI = "c:\flash\install_flash_player_10_active_x.msi" Set wshShell = CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") strComputername = wshShell.ExpandEnvironmentStrings("%COMPUTERNAME%") strInstallLog = strLogPath & "Flash_Install_" & strComputername & ".log" strInstallCMD = "msiexec /I " & strInstallMSI & " /quiet" strTempDir = wshShell.ExpandEnvironmentStrings("%TEMP%") On Error Resume Next strVersion = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Macromedia\FlashPlayerActiveX\Version") On Error Goto 0 searchCurVer = InStr(1, strVersion, strCurrentVersion, 1) If searchCurVer > 0 Then CurVerFound = True flashversion = strVersion ElseIf searchCurVer <> 0 Then CurVerFound = False End If Set ts = fso.OpenTextFile(strInstallLog, 8, True) If CurVerFound = True Then ts.WriteLine Now() & " Flash - Current version, " & flashversion & " found - No Update Needed." ts.close WScript.Quit() ElseIf CurVerFound = False Then ts.writeline now() & " Flash Not Found, New Installation started" wshshell.run(strInstallCMD) ts.writeline now() & " " & strCurrentVersion & " Installed" ts.close WScript.quit() End If
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now