Search code examples
powershelldockerdocker-for-windowswindows-container

Docker - running exe that show dialog/form from powershell file causing the fault


I have an .exe program that I need to run it in docker at startup. I can run it from powershell of container without any error but not from powershell script file.

  • container name : base
  • exe file name : abc.exe

.exe runs without any error and as expected :

  • docker-compose ecex base powershell
  • PS C:\> abc.exe -someParam xyz

But when I call it from a powershell script file it gives me following error :

runexe.ps1 file :

# run 
abc.exe -someParam xyz

error :

Unhandled Exception: System.InvalidOperationException: Showing a modal dialog 
box or form when the application is not running in UserInteractive mode is not a 
valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to
display a notification from a service application.
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)

So, how can I overcome this problem ? Thanks in advance.


Solution

  • Use Start-Process powershell cmdlet to control execution of EXE inside docker build, it allows finer control of process lifetime