I then logged out and came back to my cubicle and tried to ping the node. There was no way I could talk to it. Back to the server, I noticed that the Erlang detached process wasn't running any more.
So, here is the first conclusion: When you log out, Windows kills all the processes started by the user that was logged in. I asked the admin guy and he told me to set a task to call the batch file. This would allow me to avoid having to log in to launch the process.
That indeed solved the problem but how do you schedule the task? If you set it to start on every machine startup, the process might die or be killed and the process wouldn't be restarted until the machine is rebooted.
If you schedule it periodically, and the process hasn´t died, the second time around, the batch will crash when calling the erl command with the same "sname". Erlang will then write a crash dump file. The process that is already running will continue to run but it is not an elegant way to do it.
The "a little bit better" solution that I came up with was to run the following scrip:
tasklist /FI "IMAGENAME eq erl.exe" 2>NUL | find /I /N "erl.exe">NUL
if "%ERRORLEVEL%"=="0" goto :END
"C:/Archivos de programa/erl5.7.2/bin/erlc.exe" batz_server_app.erl bs_sup.erl bs_server.erl batz_server.erl bs_time_server.erl epsilon.erl email.erl gros97.erl
"C:/Archivos de programa/erl5.7.2/bin/erl" -boot start_sasl -sname b1 -setcookie einw -s batz_server -detached
It runs an Erlang process only if an erl.exe process is not already running on that machine.We can now call this batch periodically without worrying whether the node is already up or not.
Note that the batch would´t work right if we needed to have more than one Erlang node on the same machine.
So the second conclusion is that building standalone processes on Erlang to run on the background on a Windows machine is not the easiest thing.