Sometimes you may need to install an app with winget but with extra command line arguments, or even replace the default switches with your own ones. Winget is a built-in package manager that learns how to install an app from a manifest file. But you can override command line arguments without editing that file.
Winget is a tool that installs programs automatically using a scenario defined by the manifest from its online repository. The manifest may include any of the command line switches that the app's installer supports. However, the manifest is designed for general use. So usually it only includes silent install parameters that are fine for an average user.
But if you have specific requirements for the installation process, you need to adjust the settings to meet your goals. For that purpose, you may need to use some extra arguments that supports the installer. It's important to note that you are still limited to installer options that the app developer has created.
There are three types of tasks you may need to perform. First of all, you may need to simply specify an extra argument, and you are good to go to install your favorite app. In other case, you may need to completely override the command line for the installer. Finally, you may to run the app installer interactively. Let's review these tasks in details.
Add custom arguments to winget app installer
Winget supports the --custom
option. It is available since version 1.5. You can quickly find the winget version by running it as 'winget --version
'.
To add a custom command line argument in winget, do the following.
- Press Win + X on the keyboard, and select Terminal(Admin) from the menu.
- Type
winget install --id 7zip.7zip --custom "/D=D:\Apps\7-zip"
. In our example, 7-zip will be installed silently to a custom D:\Apps\7-zip folder. The "/D=D:\Apps\7-zip" option will be added to the "/S" key which is set by default. - Replace
7zip.7zip
with the ID for the app you are installing, and provide the required arguments.
You are done.
Override installer arguments for winget
Instead of specifying a custom argument in addition to the existing ones, you completely override the installer options for an app you are going to install with winget. There is a dedicated switch, '--override'
, for that task.
To override the installer arguments for a winget package, run it as follows.
- Open a Terminal as Administrator.
- Type
winget install --id 7zip.7zip --override "/S /D=D:\Apps\7Zip"
. All arguments in the manifest package will be replaced with what you have specified in the --override switch. - Replace the --id with the value for the app you are going to install, and specify the required args.
Generally speaking, the main distinction is that for the "--override" option, it's mandatory to specify the silent installation switch. In case of the 7-zip app it is "/S". But, for the "--custom" option, winget preserves the silent installation argument for the installer, as specified in the manifest. In case of any duplicate argument or option overlapping, the installer handles it by itself. Usually, it gives the priority to the last option specified.
How to run interactive setup of winget app
As mentioned earlier, by default winget installs apps silently without user interaction. You can change this and perform a regular install that allows you to specify desired options in the graphical user interface of the setup program.
To install a winget app interactively, do the following.
- Right-click the Start menu button in the taskbar, and select Terminal(Admin).
- Type
winget install --id 7zip.7zip -i
. Substitute--id 7zip.7zip
with the desired app ID for the software you want to install. - Follow the setup wizard prompts, as you usually do.
In this very case, winget only serves as a software downloader for you. It will provide you with an installer, but you are installing the app manually.
Now, when you know all the necessary winget options, you may wonder how to find the required supported installer switches? Here are the thing to do.
Find the available installer options
First of all, you need to find the package ID. Run the following command:
winget search <app name>
E.g. the command winget search 7-zip
gives you the following output. Pick the official one.
Next, you need to find the installer type. The following command shows what is the installer package:
winget show 7zip.7zip
Replace 7zip.7zip
with your app's ID.
In case of 7-zip, it Nullsoft Scriptable Installer System (NSIS), for which the "/S" key makes the installer run silently.
Installer types and their silent installation switches
Inno Setup
Applications that use in the free Inno Setup support the /SILENT and /VERYSILENT switches. The latter does not show a progress bar during installation. While the installation will be silent, the setup program will display a confirmation. To suppress it, combine any of the mentioned switches with /SP-. So the command line will be:
setup.exe /VERYSILENT /SP-
Nullsoft Scriptable Install System (NSIS)
Software that use the free NSIS support with the /S switch. For example, Setup.exe /S will install them silently.
Additionally, you can use the /D switch to specify the installation directory. This is what we used in our article.
Note: /S and /D must be capitalized. In case of NSIS, it is important.
WISE Installer
Apps that use WISE Installer show a splash window like this one when you launch the installer.
Some its version may display a full screen window with a dark blue background, displaying the installation window in the center. To install a WISE Installer packaged app silently, use the following command line:
Setup.exe /s
InstallShield
To find if the setup program was made with InstallShield, check out the properties of the setup.exe file. You may see something like "InstallShield (R) Setup Launcher" on the Details tab. This will clearly indicate that it is an InstallShield installer. Also, such programs often contain the setup.iss file in same directory where the setup.exe file is stored.
Silently install an app that uses InstallShield
- First run the setup.exe with the /r switch, i.e.
setup.exe /r
. InstallShield will save all your installation choices in the setup.iss file and place it in the Windows folder. - Move the setup.iss file to the same folder where you have the setup.exe file.
- Run the installer as
setup.exe /s /sms
.
Windows Installer Service (MSI)
In general, files with the *.MSI extension can be silently installed with the following command line.
setup.msi "/qn REBOOT=ReallySuppress"
The command installs the MSI file silently without showing the progress bar.
If you want to make it show a progress bar during the automated app installation, replace /qn
with /qb-!
. So the command will look as follows.
setup.msi "/qb-! REBOOT=ReallySuppress"
The exclamation point disables the Cancel button in the progress window.
InstallShield with MSI
Some variations of the InstallShield installers include MSI packages. To automatically install an application using InstallShield with MSI, you need to specify the /s /v"<MSI arguments>" switches. Replace <MSI arguments> with the options you want to pass directly to the Windows Installer. In other words, if you want to install such an application completely silently and avoid rebooting, then use this command.
setup.exe /s /v"/qn REBOOT=ReallySuppress"
Custom MSI arguments
Some of the MSI packages contain extra options that you can specify in the command prompt to modify the installer behavior. They may or may not be documented by the app developer.
However, it is easy to reveal them all by providing the /lp!
switch that will dump all the MSI extra properties to a log file. Here's a quick example on how to use it.
msiexec.exe /package PowerShell-7.3.2-win-x64.msi /lp! "%USERPROFILE%\Desktop\prop.txt"
Run the above command in cmd.exe or Windows Terminal with the Command Prompt tab. The command will save all the extra options for the PowerShell-7.3.2-win-x64.msi package to the prop.txt file on your desktop.
Besides, it will simulate the interactive installation, where to must check/apply all the options you want to see in the log file (prop.txt).
On the finish screen, close the installer to cancel the installation.
Open the prop.txt file. You will easily see the extra MSI properties written in capital letters. In the screenshot below, properties that are not set by default are highlighted in yellow. In the log file, their values are 0, but when installing, you should specify 1. For example, you can use the following extra arguments for the PowerShell installer.
msiexec.exe /package PowerShell-7.3.2-win-x64.msi /qb-! ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL=1
The same command that you can use with winget:
winget install Microsoft.PowerShell --source winget --override "/qn ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL=1"
Here we use the /qn switch to install PowerShell silently, and also enable the two context menu items.
The extra options tell the install to add the Run in PowerShell and Open PowerShell here items to the right-click of File Explorer.
Finally, if you have Windows SDK installed, it contains a GUI tool "Orca". It allows editing the MSI packages. The good thing is that it also reveals extra options for the installer!
After carefully reviewing the tables Orca shows on the left and their content on the right, you can find all the available properties without creating the log file.
That's it.
Thanks to Vadim Sterkin.
Support us
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options: