Autohotkey: updating portable software

Requirements

Installation

  1. copy/paste the code from the script below into a new file
  2. save that new file in a new folder (you can name it whatever you want)
  3. edit line 1 of the script to list the programs you want to use (by default: “ccleaner,speccy,defraggler,recuva”)
  4. run update_piriform.ahk (it will download unzip.exe if it doesn’t already exist in the same folder and start downloading/unzipping the files that are listed in the programs line)
  5. done

Usage

  1. manually run the script when you want to update the files listed on line 1
  2. done

Script

programs = ccleaner,speccy,defraggler,recuva

app_name = Piriform downloader
app_ver = 0.04
app_author = Johan Klos

/*
I use piriforms free tools to do some maintenance. 
Every so often I run this script to update the portable versions of those programs.
https://www.piriform.com/%program%/download/portable

it keeps the user informed using tooltips
*/

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance force ; skips the dialog box and replaces the old instance automatically, which is similar in effect to the Reload command.

tooltip %app_name% v%app_ver%`nStarting program

; check if commandline unzip.exe program is present, if not, download it	
ifnotexist unzip.exe
{
	tooltip %app_name% v%app_ver%`nunzip.exe missing: downloading it now
	UrlDownloadToFile, http://www.kloscomputing.co.uk/public/unzip.exe, unzip.exe
}
	
loop, parse, programs, `,
{
	if ( A_LoopField <> "" )
	{
		download(A_LoopField)
	}
}
count = 3
loop, 3
{
	tooltip %app_name% v%app_ver%`nAll done: terminating program in %count% seconds.
	count--
	sleep 1000
}
exitapp

download(program)
{
	global app_name, app_ver
	
	; create an URL to download the program in question
	url := "https://www.piriform.com/" . program . "/download/portable/downloadfile"
	
	tooltip %app_name% v%app_ver%`n%program% downloading
	; download the zip file
	UrlDownloadToFile, %URL%, %A_Temp%\%program%.zip
	
	tooltip %app_name% v%app_ver%`n%program% unzipping
	runwait, unzip.exe -u "%A_Temp%\%program%.zip" -d "%A_ScriptDir%\%program%",, hide	

	tooltip %app_name% v%app_ver%`n%program% clean up files we won't need any more
	; do some cleanup work, remove the 
	FileDelete, %A_Temp%\%program%.zip
	return
}

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Loading