AutoIt – Flash Player

At some point in the last year, the folks over at Ninite.com were asked by Adobe to stop serving Flash Player via their free service.  If you paid, you could include Flash Player in the bundle.  However, pricing for 3,500 Windows computers gets steep really quickly, in the eyes of many purse-string holders.  So here’s a bit of code that should help you get Flash out there, directly from Adobe, without a technician needing to be present. Remember to either comment out the Admin check section, or replace the credentials accordingly, so users can run it without a problem.

Selec All Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <Inet.au3>
#include <String.au3>
#include <Array.au3>
 
;Ensure running as Administrator account
If IsAdmin() = 0 Then
	RunAs("<administrator>", @ComputerName, "<password>", 1, @AutoItExe)
	Exit(2)
EndIf
 
;Pull the web page source for parsing
$tempFile = FileOpen(@TempDir & "\FPTemp.txt", 2)
FileWrite($tempFile, _InetGetSource("http://www.adobe.com/products/flashplayer/distribution3.html"))
FileClose($tempFile)
 
;Read the file, and use a regex to find our current version
$version = StringRegExp(FileRead(@TempDir & "\FPTemp.txt"), "([0-9\.]{10} \(Win and Mac\))", 3)
$version = _ArrayToString($version, "", 0, 0)
ConsoleWrite($version & @CRLF)
 
;Cut it up to get our actual version info
$netFullVer = StringLeft($version, 10)
ConsoleWrite("Full Version:  " & $netFullVer & @CRLF)
$netBigVer = StringLeft($netFullVer, 2)
ConsoleWrite("Major Version: " & $netBigVer & @CRLF)
$netTinyVer = StringRight($netFullVer, 3)
ConsoleWrite("Patch Version: " & $netTinyVer & @CRLF)
 
;Check our local version, and cut it up as well
$regFullVer = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Macromedia\FlashPlayer", "CurrentVersion")
If @error then
	ConsoleWriteError("Error reading key: " & @error & @CRLF)
	GetFlash()
	Exit
EndIf
$regFullVer = StringReplace($regFullVer, ",", ".")
$regBigVer = StringLeft($regFullVer, 2)
$regTinyVer = StringRight($regFullVer, 3)
ConsoleWrite("Local Full Version:  " & $regFullVer & @CRLF)
ConsoleWrite("Local Major Version: " & $regBigVer & @CRLF)
ConsoleWrite("Local Patch Version: " & $regTinyVer & @CRLF)
 
;Compare the major version, if the same, check minor, install as needed
If $netBigVer > $regBigVer Then
	GetFlash()
ElseIf $netBigVer >= $regBigVer And $netTinyVer > $regTinyVer Then
	GetFlash()
EndIf
 
Func GetFlash()
	InetGet("http://download.macromedia.com/get/flashplayer/current/licensing/win/install_flash_player_" & $netBigVer & "_active_x.msi", @TempDir & "\install_flash_player_" & $netBigVer & "_active_x.msi", 1)
	RunWait("msiexec.exe /qb- /i " & @TempDir & "\install_flash_player_" & $netBigVer & "_active_x.msi", @TempDir)
 
	InetGet("http://download.macromedia.com/get/flashplayer/current/licensing/win/install_flash_player_" & $netBigVer & "_plugin.msi", @TempDir & "\install_flash_player_" & $netBigVer & "_plugin.msi", 1)
	RunWait("msiexec.exe /qb- /i " & @TempDir & "\install_flash_player_" & $netBigVer & "_plugin.msi", @TempDir)
EndFunc

 

 

†: You must have a redistribution agreement with Adobe to use the MSI package.

Posted in Uncategorized.