I can execute concisecss.cmd normally by opening it with Explorer, and I have checked that I have execute permission for it (this happens for every npm program, concise is here just as an example). Is it because it is a bat script? How should I run it on Windows?
I can’t try it, but I think, you have to try to spawn it throuch cmd.exe or powershell.exe or whatever interpreter you need. Windows does not know about a concept similar to UNIX’ shebang, but has only some crippled system do determine such stuff by looking at the files ending. But this behaviour isn’t available for tools outside of windows “core” without hooping some loops.
Google says that cmd /c foo.cmd should run foo.cmd without spawning a new window.
Buf as far as I can remember from my erlang things I did, you will loose the access to the spawned programs stdin and -out, which is probably the mainreason for using a Port…
Answering myself here with the solution. The problem was that cmd scripts can’t be spawned as executables on Windows, so I had to use cmd.exe. I looked at the :os.cmd sources to see how Erlang does it and found the winning combination.
In the end, the answer was to use cmd.exe /c foo.cmd, but with a Windows-specific flag :hide to the Port opening call. That hides the opened cmd window and sends stdout correctly. Without the flag, the cmd window flashes on the screen and stdout never arrives back to BEAM.