@echo off
:: Define the paths and filenames
set GOLDSIM_EXE="C:\Program Files (x86)\GTG\GoldSim 15\GoldSim.exe"
set MODEL_DIR=C:\Users\jason\OneDrive\GoldSim_Testing\GSswmm_examples\Simple_Model
set MODEL_FILE=SimpleModel.gsm

:: Change directory to where the model is located
cd /d "%MODEL_DIR%"

:: Run GoldSim in hidden mode (-hl), run simulation (-r), and save results (-sv)
%GOLDSIM_EXE% -r -x "SimpleModel_Results.gsm" "%MODEL_FILE%"

:: Check the exit code for success or failure
if %errorlevel% NEQ 0 (
    echo.
    echo ERROR: GoldSim failed with exit code %errorlevel%.
    echo Check SimpleModel.log for details.
) else (
    echo.
    echo SUCCESS: Simulation completed and results saved to SimpleModel_Results.gsm.
)