MSYS2 Silent Install (How-To Guide)

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

MYSYS Silent Install (EXE) – Option 1

Applies to MSYS2 Versions 2021 & Newer

  1. Navigate to: https://www.msys2.org/
  2. Download the msys2-x86_64-2022XXXX.exe to a folder created at (C:\Downloads)
  3. Open an Elevated Command Prompt by Right-Clicking on Command Prompt and select Run as Administrator
  4. Navigate to the C:\Downloads folder
  5. Enter the following command:
msys2-x86_64-2022XXXX.exe install --root C:\MSYS2 --confirm-command

After a few moments you will find MSYS2 entries in the Start Menu, Installation Directory, and Programs and Features in the Control Panel.

Software Title:MSYS2
Vendor:The MSYS2 Developers
Version:2021 & Newer
Architecture:x64
Installer Type:EXE
Silent Install Switch:msys2-x86_64-2022XXXX.exe install --root C:\MSYS2 --confirm-command
Silent Uninstall Switch (Option 1)"C:\MSYS2\uninstall.exe" purge --confirm-command
Silent Uninstall Switch (Option 2)"C:\MSYS2\maintenancetool.exe" purge --confirm-command
Download Link:https://github.com/msys2/msys2-installer/releases
PowerShell Script:https://silentinstallhq.com/msys2-install-and-uninstall-powershell/

MYSYS Silent Install (EXE) – Option 2

Applies to All MSYS2 Versions

  1. Navigate to: https://repo.msys2.org/distrib/x86_64/
  2. Download the msys2-x86_64-202XXXXX.exe file of your choice 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.NextButton);
}

Controller.prototype.FinishedPageCallback = function()
{
    var page = gui.pageWidgetByObjectName("FinishedPage");
    page.RunItCheckBox.checked = false;
    gui.clickButton(buttons.FinishButton);
}
  1. Open an Elevated Command Prompt by Right-Clicking on Command Prompt and select Run as Administrator
  2. Navigate to the C:\Downloads folder
  3. Enter the following command:
msys2-x86_64-2020XXXX.exe --platform minimal --script .\silent-install.js InstallDir=C:\MSYS2\

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:x64
Installer Type:EXE
Silent Install Switch:msys2-x86_64-2020XXXX.exe --platform minimal --script .\silent-install.js InstallDir=C:\MSYS2\
Silent Uninstall Switch:"C:\MSYS2\maintenancetool.exe" --platform minimal --script .\silent-uninstall.js
Download Link:https://repo.msys2.org/distrib/x86_64/
PowerShell Script:https://silentinstallhq.com/msys2-install-and-uninstall-powershell/

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

Check out the MSYS2 Install and Uninstall (PowerShell) post for a scripted solution.

  • Open an Elevated Command Prompt by Right-Clicking on Command Prompt and select Run as Administrator
  • Enter one of the following commands:

MSYS2 Silent Uninstall (EXE) – Versions 2021 & Newer

"C:\MSYS2\uninstall.exe" purge --confirm-command
Or
"C:\MSYS2\maintenancetool.exe" purge --confirm-command

MSYS2 Silent Uninstall (EXE) – All Versions

  • 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.NextButton);
}

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
  1. Open an Elevated Command Prompt by Right-Clicking on Command Prompt and select Run as Administrator
  2. Enter one of the following commands:
"C:\MSYS2\uninstall.exe" --platform minimal --script .\silent-uninstall.js
Or
"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.

Jason Bergner

I am an accomplished Software Engineer at Patch My PC, leveraging more than 18 years of hands-on experience in Configuration Manager administration and application packaging. I am driven by a genuine passion for solving complex problems and consistently strive to discover innovative and effective solutions. Sharing my extensive knowledge of application deployments is a true joy for me, and I am honored to contribute to the community here at Silent Install HQ.

Recent Posts