MSYS2 is a collection of tools and libraries providing you with an easy-to-use environment for building, installing and running native Windows software. This article will serve as an informative guide and give you a clear understanding of how to perform a silent installation of MSYS2 from the command line using the EXE installer.
How to Install MSYS2 Silently
MSYS2 Silent Install (EXE)
- Download the MSYS2 Installer
- Download the EXE file to a folder created at (C:\Downloads)
- Open Notepad or your favorite text editor
- Add the following lines:
var target_dir = installer.value("InstallDir")
function Controller()
{
installer.setDefaultPageVisible(QInstaller.Introduction, true);
var page = gui.pageWidgetByObjectName( "ComponentSelectionPage" );
page.selectComponent( "com.msys2.root" );
page.selectComponent( "com.msys2.root.base" );
installer.setDefaultPageVisible(QInstaller.ComponentSelection, false);
installer.setDefaultPageVisible(QInstaller.StartMenuSelection, false);
installer.setDefaultPageVisible(QInstaller.LicenseCheck, false);
installer.setDefaultPageVisible(QInstaller.ReadyForInstallation, false);
installer.setDefaultPageVisible(QInstaller.PerformInstallation, true);
installer.setDefaultPageVisible(QInstaller.InstallationFinished, true);
installer.setDefaultPageVisible(QInstaller.FinishedPage, true);
ComponentSelectionPage.selectAll();
installer.autoRejectMessageBoxes();
var result = QMessageBox.question("quit.question", "Installer", "Do you want to quit the installer?",
QMessageBox.Yes | QMessageBox.No);
installer.setMessageBoxAutomaticAnswer("OverwriteTargetDirectory", QMessageBox.Yes);
installer.setMessageBoxAutomaticAnswer("stopProcessesForUpdates", QMessageBox.Ignore);
}
Controller.prototype.IntroductionPageCallback = function()
{
gui.clickButton(buttons.NextButton);
}
Controller.prototype.TargetDirectoryPageCallback = function()
{
gui.currentPageWidget().TargetDirectoryLineEdit.setText(target_dir);
gui.clickButton(buttons.NextButton);
}
Controller.prototype.StartMenuDirectoryPageCallback = function()
{
gui.clickButton(buttons.NextButton);
}
Controller.prototype.PerformInstallationPageCallback = function()
{
var page = gui.pageWidgetByObjectName("PerformInstallationPage");
installer.setAutomatedPageSwitchEnabled(true);
gui.clickButton(buttons.NextButton);
}
Controller.prototype.InstallationFinishedPageCallback = function()
{
var checkBox = gui.pageWidgetByObjectName("RunItCheckBox");
var page = gui.pageWidgetByObjectName("InstallationFinishedPage");
gui.clickButton(buttons.NexthButton);
}
Controller.prototype.FinishedPageCallback = function()
{
var page = gui.pageWidgetByObjectName("FinishedPage");
page.RunItCheckBox.checked = false;
gui.clickButton(buttons.FinishButton);
}
- Save the file to the C:\Downloads directory and name it: silent-install.js
- Reference: https://github.com/msys2/msys2-installer/blob/master/auto-install.js
- Open an Elevated Command Prompt by Right-Clicking on Command Prompt and select Run as Administrator
- Navigate to the C:\Downloads folder
- Enter the following command:
msys2-x86_64-20200903.exe --platform minimal --script silent-install.js InstallDir=C:\MSYS2\
- Press Enter
After a few moments you should see the MSYS2 entries in the Start Menu, Installation Directory, and Programs and Features in the Control Panel.
Software Title: | MSYS2 |
Vendor: | The MSYS2 Developers |
Architecture: | x86_x64 |
Installer Type: | EXE |
Silent Install Switch: |
|
Silent Uninstall Switch: | "C:\MSYS2\maintenancetool.exe" --platform minimal --script silent-uninstall.js |
Download Link: | https://repo.msys2.org/distrib/x86_64/ |
The information above provides a quick overview of the software title, vendor, silent install, and silent uninstall switches. The download links provided take you directly to the vendors website.
How to Uninstall MSYS2 Silently
- Open Notepad or your favorite text editor
- Add the following lines:
function Controller()
{
}
Controller.prototype.IntroductionPageCallback = function()
{
if (installer.isUninstaller()) {
var widget = gui.currentPageWidget();
if (widget != null) {
widget.findChild("PackageManagerRadioButton").visible = false;
widget.findChild("UpdaterRadioButton").visible = false;
widget.findChild("UninstallerRadioButton").visible = false;
}
}
gui.clickButton(buttons.NextButton);
}
Controller.prototype.ReadyForInstallationPageCallback = function()
{
var page = gui.pageWidgetByObjectName("ReadyForInstallationPage");
gui.clickButton(buttons.CommitButton);
}
Controller.prototype.InstallationFinishedPageCallback = function()
{
var page = gui.pageWidgetByObjectName("InstallationFinishedPage");
gui.clickButton(buttons.NexthButton);
}
Controller.prototype.FinishedPageCallback = function()
{
var page = gui.pageWidgetByObjectName("FinishedPage");
gui.clickButton(buttons.FinishButton);
}
- Save the file to the C:\MSYS2 directory and name it: silent-uninstall.js
- Open an Elevated Command Prompt by Right-Clicking on Command Prompt and select Run as Administrator
- Enter the following command:
MSYS2 Silent Uninstall (EXE)
"C:\MSYS2\maintenancetool.exe" --platform minimal --script silent-uninstall.js |
Always make sure to test everything in a development environment prior to implementing anything into production. The information in this article is provided “As Is” without warranty of any kind.