Pretty much what the title says, is it possible to passively/silently install an .EXE using Powershell but still have the installer GUI show? I'd want the next's "clicked" automatically but would still like the GUI to be shown as sort of a progress indicator.
2 Answers
UPDATE: There is a Powershell module for Windows Installer. It can help to run msiexec.exe equivalent commands in easier fashion than to deal with Powershell's quirks.
MSI?: If this is an MSI inside an EXE wrapper, then the below will generally work. If it is just a normal EXE file you should repackage as Painter answers - or run it silently with the correct switches - if possible.
MSI Extraction: Extract MSI from EXE.
Repackaging: Last resort is to convert EXE to MSI using capture tools.
- Quick summary on repackaging (convert setup.exe to MSI - more links: at bottom)
- How to run an installation in /silent mode with adjusted settings
Suggestion: I would suggest this command line based on what you wrote (basic UI with modal box displayed at completion & hide the cancel button during installation):
msiexec.exe /I "setup.msi" /qb+!
Sample progress dialog with hidden cancel button:
Keystrokes: It sounds like you want the whole GUI wizard to show up with all the buttons "auto-magically" clicked? That is hard. Crazy tools such as AutoIt - the ones that push keystrokes to application windows - could do it, but that is about as reliable as your average house of cards. There are always error sources in such duct-tape approaches.
Silence!: I assume you know you can suppress the whole GUI for an MSI with standard command line switches for msiexec.exe
? You can go for completely silent GUI or exactly a progress bar like you describe and many other combinations. You can even hide the cancel button. Nifty.
UILevel: MSI supports various "UILevels" - the installation can be varying degrees of interactivity from totally silent to fully interactive. There are 4 basic levels and various "modifiers" (show completion dialog or not). Here is an answer on the different UILevels in practice: Uninstall from Control Panel is different from Remove from .msi
Examples: Here are some further example command lines:
Totally silent, no GUI at all:
msiexec.exe /i "setup.msi" /qn
Basic GUI with no modal dialog boxes and hidden cancel button:
msiexec.exe /i "setup.msi" /qb-!
No GUI except a modal dialog box displayed at the end:
msiexec.exe /i "setup.msi" /qn+
Note: There are several further combinations depending on how you configure things with the 4 different levels of GUI, the modal dialog at the end or not, and finally hide or show the cancel button.
Advanced: Beyond the normal use of msiexec.exe you can suppress the whole GUI of an MSI programmatically via the MSI Win32 API and instead handle the progress messages yourself.
- Handling Progress Messages Using MsiSetExternalUI (C++ sample code, also on github.com)
- Serverfault answer on external MSI GUI
WiX Bundles: This is the approach the WiX toolkit uses to deliver its own, modern GUI for bundles. Advanced Installer and Installshield and others have similar concepts. The integration with Windows Installer is all based on these API-calls.
Links:
- Tip: User Interface Levels for MSI Installations
- Uninstall from Control Panel is different from Remove from .msi
- Run MsiExec from PowerShell and get Return Code
Repackaging:
What your describing is the difference between fully silent (no ui) and non-interactive (has a UI but the user doesn't need to interact with it). If it is a best practices following MSI then what @SteinAsmul described is your ticket.
If it's a poorly written EXE based installer that didn't consider this use case and doesn't support it then you would have to "repackage" the installer (reverse engineer / rewrite ) the installer into an MSI so that it is supported