if exist "!USERPROFILE!\.livebookdesktop.bat" (
  call "!USERPROFILE!\.livebookdesktop.bat"
)

if not defined LIVEBOOK_EPMDLESS set LIVEBOOK_EPMDLESS=true
if "!LIVEBOOK_EPMDLESS!"=="1" goto epmdless
if "!LIVEBOOK_EPMDLESS!"=="true" goto epmdless
goto continue
:epmdless
set ELIXIR_ERL_OPTIONS=!ELIXIR_ERL_OPTIONS! -epmd_module Elixir.Livebook.EPMD -start_epmd false -erl_epmd_port 0
:continue

set RELEASE_MODE="interactive"
set RELEASE_DISTRIBUTION="none"

set MIX_ARCHIVES=!RELEASE_ROOT!\vendor\archives
set MIX_REBAR3=!RELEASE_ROOT!\vendor\rebar3
if not defined LIVEBOOK_SHUTDOWN_ENABLED set LIVEBOOK_SHUTDOWN_ENABLED=true
set LIVEBOOK_DESKTOP=true
if not defined LIVEBOOK_PORT (set LIVEBOOK_PORT=0)
set PATH=!RELEASE_ROOT!\vendor\otp\erts-<%= @release.erts_version%>\bin;!RELEASE_ROOT!\vendor\otp\bin;!RELEASE_ROOT!\vendor\elixir\bin;!PATH!

if defined LIVEBOOK_NODE set RELEASE_NODE=!LIVEBOOK_NODE!
if defined LIVEBOOK_COOKIE set RELEASE_COOKIE=!LIVEBOOK_COOKIE!

if not defined RELEASE_COOKIE (
  for /f "skip=1" %%X in ('wmic os get localdatetime') do if not defined TIMESTAMP set TIMESTAMP=%%X
  set RELEASE_COOKIE=cookie-!TIMESTAMP:~0,11!-!RANDOM!
)

cd !HOMEDRIVE!!HOMEPATH!
