Unattended Installation - How to Silently Install your EXE using PowerShell & CMD?
One of the main challenges IT Pros face with application packages is the unattended installation. Unattended installations ensure that the same configuration is applied to all your active systems in the infrastructure, and no human error during installation can change that configuration.
But what is an unattended installation, how can you define it, and how can you implement it? Buckle up, and let’s find out.
What is an unattended installation?
When it comes to unattended installations, IT professionals prefer silent installations, where no UI is displayed to the user and no input is required throughout the installation. However, there are cases when unattended installations can be assisted by a GUI.
For instance, Microsoft 365 offers the possibility of having an unattended installation with a nice GUI that informs the user how long it takes until the installation is complete.
When it comes to MSI packages, the silent switches are easy and universal. A user can use:
- /qb! to show a GUI to the user but without the possibility to cancel the installation,
- /QB to allow the user to cancel the installation or
- /QN parameter for a fully silent installation.
What about EXE installers? Unfortunately, these don’t have a universal standard when it comes to silent switches, but here are some useful tips for finding out what the switches are.
General Standards for EXE Switches
Most EXE installers have an option to display a list of commands available, and this is done via the /? or /help parameters.
What are some good sources of information about silent switches?
If the above switches don’t work, the best option would be to search the web to see if the ISV has any documentation about it, or most likely find the information in trusted IT Pros forums.
A useful resource is the Silent Install HQ website, which contains command-line switches for various installers. It has a good database of applications with a set of commands for install, uninstall, and a PowerShell Application Deployment Toolkit script.
For a more in-depth review of the silent options when it comes to EXEs, check out this article: How to Find Silent Install Switches for EXE.
Once you locate the unattended command line for your installer, there are various ways you can execute it within your infrastructure. So let's take a look at how to run EXE from PowerShell and CMD.
How to run EXE from CMD?
Just like running the /? or /help command in CMD, you can also run your executable with the proper silent installation parameters. Although it’s considered a legacy technology, batch files are still very popular in the industry and are used to this day.
Batch files are more popular since they are easy to use - you just type all the CMD options you would manually run.
Batch files also offer some statements, such as IF or the option for sections, but these are very limited programmatic procedures.
The extensions for batch files are .bat, .cmd and .btm, and these can be easily created from Notepad. Just open notepad.exe and type your desired commands, then save your file with the preferred extension.
For example, running the silent installation of the VLC EXE in CMD would look like this:
Now, let’s say we want to edit a registry key after the installation. For CMD, you need to use the REG.EXE utility to perform changes on the registry.
For a full list of parameters, you can type the following:
Reg.exe /?
To combine both commands for the EXE installation and registry modification, we can create a simple batch file that only contains the following lines:
vlc-3.0.17.4-win64.exe /S /V/qn REG ADD HKLM\SOFTWARE\VideoLAN\VLC /v AppInfo /t REG_DWORD /d 1
How to run EXE from PowerShell?
There are multiple ways to silently install an EXE using PowerShell. Unlike batch files, PowerShell is a full-fledged scripting language for task automation and configuration management, consisting of a command-line shell.
If we want to run the same silent installation of VLC EXE as above, we can use the Invoke-Expression cmdlet or Start-Process.
With Invoke-Expression, we can use the following script:
$Command = "vlc-3.0.17.4-win64.exe /S /V/qn" Invoke-Expression $Command
With Start-Process, we can use the following script:
$Arguments = @( "/S" "/V/qn" ) Start-Process -FilePath “vlc-3.0.17.4-win64.exe” -ArgumentList $Arguments -Wait -NoNewWindow
As a well known PowerShell tool in the IT Pros industry, PowerShell App Deployment Toolkit ensures higher success rates for your installation due to the additional checks that are embedded into it. Moreover, it offers easy-to-use cmdlets and a standard logic that is largely used in the industry at the moment.
We have touched on the PowerShell App Deployment Toolkit utility in the free MSI Packaging Training eBook, which you can download from our website.
Check the Advanced Installer MSI Packaging Essentials online training program.Get trained and certified for FREE, 100% Online.
Start here!