From 5c0824bdceafb2df0fb9c5c07260a654345dac0d Mon Sep 17 00:00:00 2001 From: Dwayne Litzenberger Date: Sat, 2 Apr 2016 05:46:13 -0500 Subject: AutoIt3 script for installing python <= 2.3 on Windows --- tools/PythonInstall.au3 | 85 ++++++++++++++++++++++++++++++++++++++++++++ tools/PythonInstall.exe | Bin 0 -> 860160 bytes tools/win-create-pythons.sh | 10 +++--- 3 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 tools/PythonInstall.au3 create mode 100644 tools/PythonInstall.exe diff --git a/tools/PythonInstall.au3 b/tools/PythonInstall.au3 new file mode 100644 index 0000000..704de7d --- /dev/null +++ b/tools/PythonInstall.au3 @@ -0,0 +1,85 @@ +#RequireAdmin +#pragma compile(ExecLevel, requireAdministrator) +#pragma compile(Out, PythonInstall.exe) +#pragma compile(Console, true) + +Const $iTimeout = 10 +Const $iInstallTimeout = 900 + + +;Const $sProcName = "Python-2.1.2.exe" +Const $sProcName = $CmdLine[2] +Local $pid = ProcessExists($sProcName) +If Not $pid Then + $pid = Run($sProcName) + If @error Then + ; TODO + EndIf +EndIf + +Const $sWinTitle = "[REGEXPTITLE:Python 2.[123].[0-9]+ Installation]" +;Const $sDestDir = "C:\Python21" +Const $sDestDir = $CmdLine[1] + +; Wait for the wizard window to open +Local $hWnd = WinWait($sWinTitle, "&Next >", $iTimeout) +If Not IsHWnd($hWnd) Then + ; TODO +EndIf + +; Activate the window for good measure. +If Not IsHWnd(WinActivate($hWnd, "")) Then + ; TODO +EndIf + +Local $stepDestDir = False +Local $stepDestDirSet = False +Local $stepAlreadyExists = False +Local $stepReplacedFiles = False +Local $stepSelectComponents = False +Local $stepSelectStartMenuGroup = False +Local $stepReadyToInstall = False +Local $stepFinish = False +Local $timeout = False + +Local $hTimer = TimerInit() +While IsHWnd(WinGetHandle($hWnd)) Or Not $stepFinish + Select + Case Not $stepDestDirSet And ControlSetText($sWinTitle, "Select Destination Directory", "[CLASS:Edit; INSTANCE:1]", $sDestDir) + $stepDestDirSet = True + Case Not $stepDestDir And $stepDestDirSet And ControlSend($sWinTitle, "Select Destination Directory", "&Next >", "!n") + $stepDestDir = True + Case Not $stepAlreadyExists And ControlClick("Install", "The directory " & $sDestDir & " already exists", "Yes") + $stepAlreadyExists = True + Case Not $stepReplacedFiles And ControlSend($sWinTitle, "Backup Replaced Files", "&Next >", "!o!n") ; "o" -- No, don't do backups + $stepReplacedFiles = True + Case Not $stepSelectComponents And ControlSend($sWinTitle, "Select Components", "&Next >", "!n") + $stepSelectComponents = True + Case Not $stepSelectStartMenuGroup And ControlSend($sWinTitle, "Select Start Menu Group", "&Next >", "!n") + $stepSelectStartMenuGroup = True + Case Not $stepReadyToInstall And ControlSend($sWinTitle, "Ready to Install!", "&Next >", "!n") ; DEBUG FIXME + $stepReadyToInstall = True + Case Not $stepFinish And ControlSend($sWinTitle, "Installation Completed!", "&Finish", "!f") + $stepFinish = True + Case Not ProcessExists($pid) + ExitLoop + Case TimerDiff($hTimer) >= $iInstallTimeout * 1000 + $timeout = True + ExitLoop + EndSelect + Sleep(250) + ; TODO - Timeout +WEnd + +If $timeout Then + ; TODO +EndIf + +If Not $stepFinish Then + ; TODO +EndIf + +Local $success = ProcessWaitClose($pid, $iTimeout) +If Not $success Then + ; TODO +EndIf diff --git a/tools/PythonInstall.exe b/tools/PythonInstall.exe new file mode 100644 index 0000000..b3dd737 Binary files /dev/null and b/tools/PythonInstall.exe differ diff --git a/tools/win-create-pythons.sh b/tools/win-create-pythons.sh index 90cf920..eff6d6b 100644 --- a/tools/win-create-pythons.sh +++ b/tools/win-create-pythons.sh @@ -23,7 +23,8 @@ # Designed to run under "Git Bash" (mingw bash) on Windows set -e -PREFIX=${PREFIX:-$(perl -e 'use Cwd; use File::Basename; print dirname(Cwd::abs_path($ARGV[0]));' "$0")/py} +toolsdir=$(perl -e 'use Cwd; use File::Basename; print dirname(Cwd::abs_path($ARGV[0]));' "$0") +PREFIX=${PREFIX:-$toolsdir/py} # Unexport vars export -n PREFIX @@ -90,9 +91,10 @@ EOF # Install # set -x -cmd //c Python-2.1.2.exe -cmd //c Python-2.2.3.exe -cmd //c Python-2.3.5.exe +cp -f "$toolsdir"/PythonInstall.exe . +cmd //c PythonInstall.exe C:\\Python21 Python-2.1.2.exe +cmd //c PythonInstall.exe C:\\Python22 Python-2.2.3.exe +cmd //c PythonInstall.exe C:\\Python23 Python-2.3.5.exe msiexec //passive //i python-2.4.4.msi ALLUSERS=1 msiexec //passive //i python-2.5.4.msi ALLUSERS=1 msiexec //passive //i python-2.5.4.amd64.msi ALLUSERS=1 TARGETDIR=C:\\Python25-64\\ -- cgit v1.2.1