@echo off
setlocal
title MCom - DocuCom
cd /d "%~dp0"
set "TARGET=%~dp0..\..\repos\mcom-docucom\target\release\docucom.exe"

if not exist "%TARGET%" (
  echo [MCom] DocuCom no esta instalado en este equipo.
  echo Abriendo la pagina de instalacion...
  start "" "http://127.0.0.1:8092/app/app-prod-documcoms"
  endlocal
  exit /b 0
)

start "" "%TARGET%"

rem Asistente MCom acoplado: ventana aparte junto a DocuCom.
set "CHROME=%ProgramFiles%\Google\Chrome\Application\chrome.exe"
if not exist "%CHROME%" set "CHROME=%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe"
if exist "%CHROME%" (
  start "" "%CHROME%" --app="http://127.0.0.1:8092/asistente?app=DocuCom" --window-size=430,780
) else (
  start "" "http://127.0.0.1:8092/asistente?app=DocuCom"
)
endlocal
