@echo off setlocal rem This file can be copied directly to the Windows Startup folder. rem The JAR is expected to be in the same directory as this BAT file. set "MES_CLIENT_HOME=%~dp0" set "MES_CLIENT_HOME=%MES_CLIENT_HOME:~0,-1%" rem If the JAR is installed outside the Startup folder, set its full path here. rem Example: set "MES_CLIENT_JAR=C:\MesClient\mesclient.jar" set "MES_CLIENT_JAR=D:\mesclient-sd.jar" rem An optional first argument can also explicitly select the JAR file. if not "%~1"=="" set "MES_CLIENT_JAR=%~1" if not defined MES_CLIENT_JAR ( for %%F in ("%MES_CLIENT_HOME%\*.jar") do ( set "MES_CLIENT_JAR=%%~fF" goto :jar_found ) ) :jar_found if not defined MES_CLIENT_JAR exit /b 1 if not exist "%MES_CLIENT_JAR%" exit /b 1 cd /d "%MES_CLIENT_HOME%" rem Keep the process independent of the Startup-folder command window. if exist "%MES_CLIENT_HOME%\lib" ( start "MES Client" /b javaw -cp "%MES_CLIENT_JAR%;%MES_CLIENT_HOME%\lib\*" com.mes.ui.MesClient ) else ( start "MES Client" /b javaw -jar "%MES_CLIENT_JAR%" ) endlocal