Thread Tools Display Modes
10-23-09, 08:01 AM   #1
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
CarboniteUpdater (autoit)

I created a simple AutoIT3-Beta script that will let you update (or install a fresh copy) of Carbonite using Wowinterface latest ZIP file. It's not perfect but it's a start.

I use Windows 7 but it should work for Vista and Windows XP!

Code:
TraySetClick(0)
#include <INet.au3>

; The URL for the download ZIP (using Wowinterface as "lastest version" repository)
Global $zipurl = "http://www.wowinterface.com/downloads/download12965-Carbonite"

; Variables for later use...
Global $forceUpdate = False
Global $versionConversion = False

; Get game information and addon version
Global $installpath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Blizzard Entertainment\World of Warcraft", "InstallPath")
If $installpath == "" And @error Then
	MsgBox(16, "Ops, can't find World of Warcraft!", "The game is not installed correctly. Please update the addon manually because the updater can't find the game path -sorry!")
	Exit
EndIf
$tocversion = FileRead($installpath & "\interface\addons\carbonite\carbonite.toc")
$tocversion = StringLower($tocversion)
$tocversion = StringRegExp($tocversion, "## version: (.*)", 1)
If @error Or UBound($tocversion) <> 1 Then
	Local $reply = MsgBox(52, "Carbonite is not installed...", "Would you like the updater to install Carbonite (fresh install)?")
	If $reply == 6 Then
		$forceUpdate = True
	Else
		Exit
	EndIf
Else
	$tocversion = StringRegExpReplace($tocversion[0], "\D", "")
EndIf

; Get page header data using winhttp (skip if forceupdate is requested)
If $forceUpdate == False Then
	$winhttp = ObjCreate("winhttp.winhttprequest.5.1")
	$winhttp.open("GET", $zipurl)
	$winhttp.send()
	;~ $headers = $winhttp.GetAllResponseHeaders

	; Assign values to variables
	$filesize = $winhttp.GetResponseHeader("Content-Length") + 0 ; force str to int
	$filetype = $winhttp.GetResponseHeader("Content-Type")
	$filedisp = $winhttp.GetResponseHeader("Content-Disposition")
	$fileenc = $winhttp.GetResponseHeader("Content-transfer-encoding")

	;~ MsgBox(0,"",$filesize) "# bytes"
	;~ MsgBox(0,"",$filetype) "application/zip"
	;~ MsgBox(0,"",$filedisp) '="(.*?)"'
	;~ MsgBox(0,"",$fileenc) "binary"

	; Terminate if file is too small (404 page error, server load, e.g.)
	If Not IsNumber($filesize) Or $filesize < 262144 Then
		MsgBox(48, "Wowinterface.com seems to be too busy!", "Unable to fetch the latest addon version, try again later!")
		Exit
	EndIf

	; Get version from content-disposition ("Carbonite-3.23.zip" becomes "")
	$filenames = StringRegExp($filedisp, "=""(.*?)""", 1)
	If @error Or UBound($filenames) <> 1 Then
		Local $reply = MsgBox(52, "Unable to fetch addon version!", "Unable to read addon version from zip, click ""Yes"" to enforce an update or ""No"" to exit.")
		If $reply == 6 Then
			$forceUpdate = True
		Else
			Exit
		EndIf
	Else
		$version = StringRegExpReplace($filenames[0], "\D", "")
	EndIf

	; Format our versions properly now
	Local $longlen = StringLen($tocversion)
	If StringLen($version) > StringLen($tocversion) Then
		$longlen = StringLen($version)
	EndIf
	While StringLen($version) < $longlen
		$version = $version & "0"
	WEnd
	While StringLen($tocversion) < $longlen
		$tocversion = $tocversion & "0"
	WEnd
	$version = $version + 0
	$tocversion = $tocversion + 0
	$versionConversion = True

	; Check versions and decide if it should update or not
	If $version > $tocversion Then
		$forceUpdate = True
	EndIf
EndIf

; Update the local addon using remote zip-file
If $forceUpdate == True Then
	If $versionConversion == True Then
		Local $reply = MsgBox(68, "New version found!", "Do you want to update (from """ & $tocversion & """) to """ & $version & """?")
		If $reply == 6 Then
			UpdateAddon()
		Else
			Exit
		EndIf
	Else
		UpdateAddon()
	EndIf
Else
	MsgBox(64, "Information", "Nothing to update, you either..." & @CRLF & "1) Have the latest version" & @CRLF & "2) Have chosen to abort updating")
EndIf

; Function to update addon
Func UpdateAddon()
	Local $7zip = @TempDir & "\7z.exe"
	FileInstall("D:\Program Files\7-Zip\7z.exe", $7zip, 1)
	Local $tempfile = @TempDir & "\Carbonite_" & @YEAR & @MON & @MDAY & "-" & @HOUR & @MIN & @SEC & ".zip"
	FileDelete($tempfile)
	Local $inetsize = InetGetSize($zipurl)
	Local $handle = InetGet($zipurl, $tempfile, 1, 1)
	While InetGetInfo($handle, 0) < $inetsize
		TrayTip("Downloading...", Round((InetGetInfo($handle, 0) / $inetsize) * 100, 0) & "% downloaded", 1)
		Sleep(25)
	WEnd
	TrayTip("Downloading...", "100% downloaded", 1)
	Sleep(250)
	TrayTip("", "", 0)
	DirCreate($installpath & "\Interface")
	DirCreate($installpath & "\Interface\Addons")
	TrayTip("Installing...", "Please wait...", 3)
	Local $exe = @TempDir & '\7z.exe x -y -o"' & $installpath & "\Interface\Addons" & '" "' & $tempfile & '"'
	RunWait($exe, @TempDir, @SW_HIDE)
	TrayTip("Installing...", "Done!", 3)
	Sleep(250)
	FileDelete($tempfile)
	TrayTip("", "", 0)
	MsgBox(64, "Done!", "The update was completed, you are now using the latest Carbonite available!")
EndFunc

; Bye!
Exit
link removed

I don't expect anything, it didn't take much time to make and I was bored! :P

Last edited by Dolby : 10-23-09 at 11:43 AM. Reason: removed link to exe
 
10-23-09, 11:45 AM   #2
Dolby
PPAP
 
Dolby's Avatar
WoWInterface Admin
Join Date: Feb 2004
Posts: 2,341
Received a few hits on virustotal from the linked exe. I think they were false positives but we don't allow linking to remote exe's.

http://www.virustotal.com/analisis/2...7f7-1256319730
 
10-23-09, 11:23 PM   #3
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
OR: You could just use MMOUIMinion. Works really well.
 
10-24-09, 12:51 AM   #4
Cairenn
Credendo Vides
 
Cairenn's Avatar
Premium Member
WoWInterface Admin
Join Date: Mar 2004
Posts: 7,134
What jeffy said. Minion.
__________________
“Do what you feel in your heart to be right — for you’ll be criticized anyway.” ~ Eleanor Roosevelt
~~~~~~~~~~~~~~~~~~~
Co-Founder & Admin: MMOUI
FaceBook Profile, Page, Group
Avatar Image by RaffaeleMarinetti
 
10-25-09, 01:51 PM   #5
Harshmage
Different
 
Harshmage's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 9
AutoIt FTW! Jebus, is there nothing AutoIT can't do?

Oh, and I can identify why a few of those virus scanners claimed the compiled .exe were a bit off: AutoIt is very powerful, and thus, in the wrong hands, can cause damage. At least NOD32 didn't flag it!

Though I may lift your script, Vladinator, to possibly pull all of my addons from the various websites (WoWi, Curse, and the single addon sites). While I know that Minion does well, and Curse has it's own, I'd rather have just one updater app, even if it takes full control of my browser.
__________________
-Bryan-
http://www.harshmage.com/

Last edited by Harshmage : 10-25-09 at 01:57 PM.
 
 

WoWInterface » Featured Projects » Carbonite » Carbonite Archive » CarboniteUpdater (autoit)

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off