2

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.

user8114848
  • 123
  • 1
  • 10
  • Hmmm, There are way to interact with installer window using PInvoke but I am not too familiar with this. Instead, I'd suggest calling the install process with the silent switch (/s but might vary for each installer) and having a Powershell Progress bar while it install as your cue that the software install is progresing. That would be also more robust when installing newer version of the software as the silent switch should not change. As for the GUI, it might change from one version to another and possibly break the automation in place. – Sage Pourpre Jan 17 '20 at 22:08
  • I found a similar question with a similar answer to my comment: https://stackoverflow.com/a/52007652/934946 You could look at Chocolatey to see the behavior they use when installing a program. Chocolatey will do the Silent install with some progress displayed on screen. I'd inspire myself there rather than trying to show the GUI and automate clicks. – Sage Pourpre Jan 17 '20 at 22:13

2 Answers2

4

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.


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:

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.

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:

Repackaging:

Stein Åsmul
  • 34,628
  • 23
  • 78
  • 140
0

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

Christopher Painter
  • 52,390
  • 6
  • 60
  • 97
  • Good point, I should have added the link to [extract MSI from EXE](https://stackoverflow.com/questions/1547809/extract-msi-from-exe/24987512#24987512). – Stein Åsmul Jan 19 '20 at 14:09