如何在Appveyor CI上自动安装Windows安装程序

107次阅读
没有评论

问题描述

想要在Appveyor CI上自动下载并安装一个EXE格式的安装程序(mt5setup.exe),但该安装程序没有静默安装的标志。用户想知道如何在无头模式下自动化安装过程。

解决方案

请注意以下操作注意版本差异及修改前做好备份。

方案1

可以使用AutoHotkey(AHK)来自动化Windows应用程序的安装过程,类似于Winetricks为所有支持的常见应用程序所做的操作。
以下是一个使用AHK脚本来安装上述应用程序的示例:

Run, mt5setup.exe
WinWait, MetaTrader 5 Setup
ControlClick, Button1
Sleep 100
ControlClick, Button3
WinWait, MetaTrader 5 Setup, Installation successfully completed
ControlClick, Button4
Process, Wait, terminal.exe
Process, Close, terminal.exe

要将其与CI集成,需要通过下载ZIP文件并解压缩来安装AHK,并传递上述AHK脚本。建议的appveyor.yml文件如下:

install:
- curl -sLo https://www.metatrader5.com/en/download
- curl -sLo http://www.autohotkey.com/download/AutoHotkey104805.zip
- unzip *.zip
before_test:
- dir
test_script:
- AutoHotkey.exe install.ahk
build: off
platform: x86

其中install.ahk是包含上述AHK脚本的文件,可以动态生成或从某个存储库下载。

方案2

另一种选择是使用Chocolatey。Chocolatey是一个Windows软件包管理器,可以用于自动化安装和管理软件。
以下是使用Chocolatey安装mt5setup.exe的示例:

choco install mt5setup -y

在上面的示例中,我们使用Chocolatey的choco install命令来安装mt5setup.exe。-y标志用于自动确认安装。
请注意,使用第三方工具来自动化安装过程可能会增加复杂性,并且需要确保安装程序和工具的依赖关系正确设置。
以上是两种在Appveyor CI上自动安装Windows安装程序的解决方案。根据你的需求和偏好,选择适合你的方法即可。

正文完