Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Automated Download & Install - Winzip


  • Please log in to reply
No replies to this topic
Kerry
  • Members
  • 144 posts
  • Last active: Sep 25 2006 07:33 PM
  • Joined: 20 Jul 2006
Hey, I got this program about a day and a half ago while looking for something to do macros... and I've stopped eating, sleeping & working since I've downlaoded this program (ok, not completely, but its very hard to drag me away from the computer)

Anyway, I spent a lot of time with this program, not because it was hard to do but I plan on making many more installation files, and I wanted something that I could easily edit and that would work everytime, and I just happened to use Winzip for my first one because AutoIt had an example to do it, which I editted slightly.

This script will download (if you want) and install winzip, or you can specify a location on your harddrive of the file. It includes and MD5 check to make sure its the right version of the program.

I'm really looking for suggestions and comments, especially in regards to making this a more universal thing (so that it's actually useful and the general script can be reused. In the final version, it will probably have more includes so that you can just include a script and this one file is very easily changed. I will probably try to get it to read a .ini file so that people can change certain values if they want.

winzip.ahk
;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         Kerry Jones <[email protected]>
;
; Script Function:
;	WinZip® 10.0 automated download and install. 
;
;

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.

File = winzip100.exe
MD5 = 504443BD49F9EAA2908756DB4413E3D2

MsgBox 4, Download WinZip® 10.0 Setup, Would you like to download WinZip® 10.0 Setup? If not, it will assume you have already done so.
IfMsgBox Yes
{
	MsgAns = Yes
	MyGuiMessage = the folder you would like WinZip® 10.0 Setup to be downloaded to
	MyGuiOption = selfolder
} Else
{
	MsgAns = No
	MyGuiMessage = winzip100.exe
	MyGuiOption = selfile
}

#Include gui.ahk ; Gui screen asking for folder or file name

If MsgAns = Yes
{	
	DownloadWinzip(location)
	location = %location%\%File%
	RunMD5(location, md5)
	InstallWinzip(location)
	ExitApp
} Else
{
	RunMD5(location, md5)
	InstallWinzip(location)
	ExitApp
}

checkmd5(md5, path, failure, title) ;Compares md5 to a file
{
	VarSetCapacity(md5sum, 32)
	DllCall("MD5Lib.dll\hexMD5", "str", md5sum, "str", Path)
	
	If md5sum = %md5%
	{
		Return True
	} Else 
	{
		MsgBox 4, %title%, %failure%
		IfMsgBox No
		{
			ExitApp
		} Else
		{
			Return False
		}
	}
	
	;FileAppend, %md5sum%`t%Path%`r`n, G:\Documents and Settings\Kerry\Desktop\MD5Sums.txt

	;FileSelectFolder, Path
	;hModule := DllCall("LoadLibrary", "str", "MD5Lib.dll")  ; Avoids the need for DllCall() in the loop to load the library.
	;Loop, %Path%\*.*, , 1
	;{
	;   DllCall("MD5Lib.dll\hexMD5", "str", md5sum, "str", A_LoopFileFullPath)
	;   FileAppend, %md5sum%`t%A_LoopFileFullPath%`r`n, %Path%\MD5Sums.txt
	;}
	;DllCall("FreeLibrary", "UInt", hModule)  ; It is best to unload the DLL after using it (or before the script exits).
}


RunMD5(path, md5)
{
	path = %path%
	FailureMsg = I'm sorry, the MD5 hash check has failed, meaning your file is invalid.  It is suggested that you cancel this install and find another location to download winzip100.exe. Do you want to continue?
	Title = MD5 Hash winzip100.exe Failure
	qResult := CheckMD5(md5, path, FailureMsg, Title)
	Return
}

DownloadWinzip(folder)
{
	loc =
( Join
http://software-files.download.com/sd/tvj87G9LVRkc2Zt7pkVvko9y-
lVGC33D89EdJAX9-wUPcmvfG-wHD56O9X31SYLqyE3Af1uwiwlb4B1JiA_
32RSrTz4s_gjt/software/10454671/10003164/3/winzip100.exe?
ptype=3001&ontid=2250&siteId=4&edId=3&pid=10454671&psid=10003164
) [color=darkred]; [Moderator][/color]
	Critical
	UrlDownloadToFile, %loc%, %folder%/winzip100.exe
	Return
}

InstallWinzip(location)
{		
		Run %Location%

		; Initial Setup Screen
		WinWaitActive WinZip® 10.0 Setup, &Setup
		Send !s

		; Install location
		WinWaitActive WinZip Setup, into the following folder
		Send {ENTER}

		; Features overview
		WinWaitActive WinZip Setup, WinZip features include
		Send !n

		; License agreement
		WinWaitActive License Agreement
		Send !y

		; Quick start
		WinWaitActive WinZip Setup, Quick Start Guide
		Send !n

		; Choose interface
		WinWaitActive WinZip Setup, switch between the two interfaces
		Send !c
		Send !n

		; Installation type (custom/express)
		WinWaitActive WinZip Setup, &Express setup (recommended)
		Send !e
		Send !n

		; Select file associations
		WinWaitActive WinZip Setup, WinZip needs to associate itself with your archives
		Send !n

		; Completed installation screen
		WinWaitActive WinZip Setup, Thank you for installing this evaluation version
		Send {ENTER}

		; Wait for winzip to load then close it
		WinWaitActive WinZip (Evaluation Version)
		WinClose WinZip (Evaluation Version)

		MsgBox WinZip® 10.0 has been successfully installed!
}
	GuiClose:
		ExitApp
	

gui.ahk
;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         Kerry Jones <[email protected]>
;
; Script Function:
;	Creates a GUI interface with the right predefined variables (this is an included file)
;

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.

Gui, Font, S10 CDefault, Verdana
Gui, Add, Text, x26 y17 w420 h40 +Center, Browse for the location of %MyGuiMessage%
Gui, Add, Button, x336 y67 w110 h25 +Center, Browse...
Gui, Add, Edit, x26 y67 w290 h25 vLoc,
Gui, Add, Button, x185 y127 w110 h30 +Center, OK
; Generated using SmartGUI Creator 4.0
Gui, Show, x131 y91 h185 w470, Winzip Location
Return

ButtonBrowse...:
	if MyGuiOption = selfile
	{
		FileSelectFile, Location
	} else if MyGuiOption = selfolder 
	{
		FileSelectFolder, Location
	}
	Loc = %Location%
	GuiControl,, Loc, %Loc%
Return
	
ButtonOK:
	If MyGuiOption = selFile 
	{
		StringRight nFile, Location, 13
		If MyGuiMessage <> %nFile% 
		{
			MsgBox The file you selected is not the correct file and will not run properly.  Please search your computer for %MyGuiMessage%
			Return
		}
	}
	Gui, Destroy

Sincerely,
Kerry