From a557d04a0dcf8054bcca0aff0a5ab582e8235a3c Mon Sep 17 00:00:00 2001 From: CarmenGlez20 Date: Sat, 23 May 2026 11:17:13 -0600 Subject: [PATCH] fix bat para funcionar en CMD y PowerShell --- install.bat | 46 +++++++++++----------------------------------- start.bat | 12 +++++++++--- 2 files changed, 20 insertions(+), 38 deletions(-) diff --git a/install.bat b/install.bat index 4458014..86d5017 100644 --- a/install.bat +++ b/install.bat @@ -1,5 +1,8 @@ @echo off -setlocal enabledelayedexpansion +setlocal + +set "ROOT=%~dp0" +if "%ROOT:~-1%"=="\" set "ROOT=%ROOT:~0,-1%" echo ============================================ echo EcoTrack Celaya - Instalador automatico @@ -7,73 +10,46 @@ echo Equipo BioCode - ITC / TecNM 2026 echo ============================================ echo. -:: Guardar la ruta raiz del proyecto (donde esta este .bat) -set "ROOT=%~dp0" -:: Quitar la barra al final -if "%ROOT:~-1%"=="\" set "ROOT=%ROOT:~0,-1%" - -:: Verificar Node.js echo [1/4] Verificando Node.js... node --version >nul 2>&1 if %errorlevel% neq 0 ( echo ERROR: Node.js no esta instalado. - echo Descargalo en https://nodejs.org y vuelve a ejecutar este archivo. + echo Descargalo en https://nodejs.org pause exit /b 1 ) echo OK - Node.js detectado. -:: Verificar Python echo [2/4] Verificando Python... python --version >nul 2>&1 if %errorlevel% neq 0 ( echo ERROR: Python no esta instalado. - echo Descargalo en https://python.org y vuelve a ejecutar este archivo. + echo Descargalo en https://python.org pause exit /b 1 ) echo OK - Python detectado. -:: Instalar dependencias del frontend -echo [3/4] Instalando dependencias del frontend (npm install)... +echo [3/4] Instalando frontend... cd /d "%ROOT%\ecotrack" -if %errorlevel% neq 0 ( - echo ERROR: No se encontro la carpeta ecotrack. - echo Asegurate de que install.bat este en la carpeta raiz del proyecto. - pause - exit /b 1 -) call npm install if %errorlevel% neq 0 ( - echo ERROR al instalar dependencias del frontend. + echo ERROR al instalar frontend. pause exit /b 1 ) echo OK - Frontend listo. -:: Instalar dependencias del backend -echo [4/4] Instalando dependencias del simulador... +echo [4/4] Instalando simulador... cd /d "%ROOT%\simulador-backend" -if %errorlevel% neq 0 ( - echo ERROR: No se encontro la carpeta simulador-backend. - pause - exit /b 1 -) python -m venv venv call "%ROOT%\simulador-backend\venv\Scripts\activate.bat" pip install fastapi uvicorn -if %errorlevel% neq 0 ( - echo ERROR al instalar dependencias del backend. - pause - exit /b 1 -) echo OK - Simulador listo. echo. echo ============================================ -echo Instalacion completada exitosamente! -echo Ahora haz doble clic en start.bat +echo Listo. Ahora haz doble clic en start.bat echo y abre http://localhost:5174 echo ============================================ -echo. -pause +pause \ No newline at end of file diff --git a/start.bat b/start.bat index 3ab6978..82c957d 100644 --- a/start.bat +++ b/start.bat @@ -1,7 +1,10 @@ @echo off setlocal -:: Ruta raiz del proyecto +:: Forzar CMD aunque se ejecute desde PowerShell +if "%COMSPEC%"=="" set COMSPEC=cmd.exe + +:: Obtener ruta raiz set "ROOT=%~dp0" if "%ROOT:~-1%"=="\" set "ROOT=%ROOT:~0,-1%" @@ -11,13 +14,16 @@ echo Equipo BioCode - ITC / TecNM 2026 echo ============================================ echo. -start "Simulador Backend" cmd /k "cd /d "%ROOT%\simulador-backend" && venv\Scripts\activate && uvicorn main:app --reload --port 8000" +:: Abrir simulador en CMD nativo +cmd.exe /c start "Simulador Backend" cmd.exe /k "cd /d "%ROOT%\simulador-backend" && venv\Scripts\activate && uvicorn main:app --reload --port 8000" timeout /t 3 /nobreak -start "Frontend React" cmd /k "cd /d "%ROOT%\ecotrack" && npm run dev" +:: Abrir frontend en CMD nativo +cmd.exe /c start "Frontend React" cmd.exe /k "cd /d "%ROOT%\ecotrack" && npm run dev" echo. echo Sistema iniciado. Abre tu navegador en: echo http://localhost:5174 echo. +pause \ No newline at end of file