How to start Phoenix application without showing terminal in Windows 11

Answer

Following an SO post:

I was able to create a shortcut that achieves my purposes, using VB as well. At the very least, this will launch the application. Closing may be another concern and I still need to test this with Elixir Desktop. However, these are questions that likely deserve their own posts, so if I find the need, I will leave them for later.

Instructions

  1. Follow instructions to create the project from the question above (you may need to enable server options in config/prod.exs)

  2. Go to demo_umbrella\_build\prod\rel\demo\bin where the newly created demo.bat file is

  3. Create a file called invisible.vbs and add in the following content:

CreateObject("Wscript.Shell").Run "" & WScript.Arguments(0) & "", 0, False
  1. Create a Windows shortcut, that looks like this:

Screenshot 2023-10-13 114923

The value on the Target field is:

%windir%\system32\wscript.exe invisible.vbs "demo.bat start"

  1. Upon clicking the shortcut, the application will be launched behind the scenes and you will be able to check it under localhost:4000.

This shortcut will run the files from the folder it is in, so you can safely move things around provided you always keep it in the same folder the rest of the files are.

Being a shortcut, it also means you can change the icon to anything you want.

1 Like