1@echo off 2setlocal 3 4rem 5rem Copyright (c) 1999, 2021 Tanuki Software, Ltd. 6rem http://www.tanukisoftware.com 7rem All rights reserved. 8rem 9rem This software is the proprietary information of Tanuki Software. 10rem You shall use it only in accordance with the terms of the 11rem license agreement you entered into with Tanuki Software. 12rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html 13rem 14rem Java Service Wrapper script - Run as a console application. 15rem 16 17rem ----------------------------------------------------------------------------- 18rem These settings can be modified to fit the needs of your application 19rem Optimized for use with version 3.5.45 of the Wrapper. 20 21rem The base name for the Wrapper binary. 22set _WRAPPER_BASE=wrapper 23 24rem The directory where the Wrapper binary (.exe) file is located. It can be 25rem either an absolute or a relative path. If the path contains any special 26rem characters, please make sure to quote the variable. 27set _WRAPPER_DIR= 28 29rem The name and location of the Wrapper configuration file. This will be used 30rem if the user does not specify a configuration file as the first parameter to 31rem this script. 32rem If a relative path is specified, please note that the location is based on the 33rem location of the Wrapper executable. 34set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" 35 36rem Makes it possible to override the Wrapper configuration file by specifying it 37rem as the first parameter. 38rem set _WRAPPER_CONF_OVERRIDE=true 39 40rem _PASS_THROUGH controls how the script arguments should be passed to the 41rem Wrapper. Possible values are: 42rem - commented or 'false': the arguments will be ignored (not passed). 43rem - 'app_args' or 'true': the arguments will be passed through the Wrapper as 44rem arguments for the Java Application. 45rem - 'both': both Wrapper properties and Application arguments can be passed to 46rem the Wrapper. The Wrapper properties come in first position. The 47rem user can optionally add a '--' separator followed by application 48rem arguments. 49rem NOTE - If _WRAPPER_CONF_OVERRIDE is set to true the above applies to arguments 50rem starting with the second, otherwise it applies to all arguments. 51rem set _PASS_THROUGH=app_args 52 53rem If there are any errors, the script will pause for a specific number of seconds 54rem or until the user presses a key. (0 not to wait, negative to wait forever). 55set _WRAPPER_TIMEOUT=-1 56 57rem Do not modify anything beyond this point 58rem ----------------------------------------------------------------------------- 59 60rem 61rem Resolve the real path of the wrapper.exe 62rem For non NT systems, the _REALPATH and _WRAPPER_CONF values 63rem can be hard-coded below and the following test removed. 64rem 65if "%OS%"=="Windows_NT" goto nt 66echo This script only works with NT-based versions of Windows. 67goto :eof 68 69:nt 70rem Find the application home. 71rem if no path path specified do the default action 72IF not DEFINED _WRAPPER_DIR goto dir_undefined 73set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" 74if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" 75rem check if absolute path 76if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path 77if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path 78rem everythig else means relative path 79set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" 80goto pathfound 81 82:dir_undefined 83rem Use a relative path to the wrapper %~dp0 is location of current script under NT 84set _REALPATH="%~dp0" 85goto pathfound 86:absolute_path 87rem Use an absolute path to the wrapper 88set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" 89 90:pathfound 91rem 92rem Decide on the specific Wrapper binary to use (See delta-pack) 93rem 94if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 95if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 96if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 97:x86_32 98set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" 99set _BIN_BITS="32" 100goto search 101:amd64 102set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" 103set _BIN_BITS="64" 104goto search 105:ia64 106set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" 107set _BIN_BITS="64" 108goto search 109:search 110set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" 111if exist %_WRAPPER_EXE% goto check_lic_bits 112set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" 113if exist %_WRAPPER_EXE% goto conf 114if %_BIN_BITS%=="64" goto x86_32 115echo Unable to locate a Wrapper executable using any of the following names: 116echo %_WRAPPER_L_EXE% 117echo %_WRAPPER_EXE% 118goto preexitpause 119 120:check_lic_bits 121if %_BIN_BITS%=="64" ( 122 set _CHECK_LIC_BITS=true 123) 124 125rem 126rem Find the wrapper.conf 127rem 128:conf 129if [%_WRAPPER_CONF_OVERRIDE%]==[true] ( 130 set _WRAPPER_CONF="%~f1" 131 if not [%_WRAPPER_CONF%]==[""] ( 132 shift 133 goto conf 134 ) 135) 136set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" 137 138rem The command should not be called inside a IF, else errorlevel would be 0 139if not [%_CHECK_LIC_BITS%]==[true] goto conf 140%_WRAPPER_EXE% --request_delta_binary_bits %_WRAPPER_CONF% > nul 2>&1 141if %errorlevel% equ 32 ( 142 set _LIC32_OS64=true 143 set _CHECK_LIC_BITS=false 144 goto x86_32 145) 146 147:conf 148if [%_PASS_THROUGH%]==[true] ( 149 set _PASS_THROUGH=app_args 150) 151if [%_PASS_THROUGH%]==[app_args] ( 152 set _PARAMETERS=-- 153 set ARGS_ARE_APP_PARAMS=true 154 set _PASS_THROUGH_ON=true 155) 156if [%_PASS_THROUGH%]==[both] ( 157 set _PASS_THROUGH_ON=true 158) 159if not [%_PASS_THROUGH_ON%]==[true] ( 160 set _PASS_THROUGH=false 161) 162 163if not [%1]==[] ( 164 if [%_PASS_THROUGH%]==[false] ( 165 echo Additional arguments are not allowed when _PASS_THROUGH is set to false. 166 goto preexitpause 167 ) 168) 169 170rem Collect all parameters 171:parameters 172if [%1]==[] goto callcommand 173if [%ARGS_ARE_APP_PARAMS%]==[true] goto append 174if [%1]==[--] ( 175 set ARGS_ARE_APP_PARAMS=true 176 goto append 177) 178rem So we are appending a wrapper property. 179rem 1) Check it is wrapped inside double quotes. 180if not ["%~1"]==[%1] ( 181 if not [%_MISSING_QUOTES_REPORTED%]==[true] ( 182 set _MISSING_QUOTES_REPORTED=true 183 echo WARNING: Any property assignment before '--' should be wrapped inside double quotes on Windows. In a powershell prompt command, double quotes should be escaped with backquote characters ^(^`^). 184 ) 185 rem If not wrapped inside quotes, the following tests are not relevant, so skip them. Should we stop? We always used to continue.. but the Wrapper will probably fail. 186 goto append 187) 188rem 2) Check that the arg matches the pattern of a property (the command should be outside of a IF block for errorlevel to be correct) 189echo %1 | findstr ^wrapper\..*\=.*$ > nul 2>&1 190if %errorlevel% equ 0 goto append 191echo %1 | findstr ^.*\=.*$ > nul 2>&1 192if %errorlevel% equ 0 goto unkown_property 193rem Not a valid assignment. 194echo WARNING: Encountered an invalid configuration property assignment '%~1'. When PASS_THROUGH is set to 'both', any argument before '--' should be in the format '^<property_name^>=^<value^>'. 195goto append 196:unkown_property 197rem The property name is not starting with 'wrapper.' so invalid. 198rem Extract the property name (this should be outside of a IF-ELSE block) 199for /f "tokens=1* delims==" %%a in ("%~1") do set _COMMAND_PROP=%%a 200echo WARNING: Encountered an unknown configuration property '%_COMMAND_PROP%'. When PASS_THROUGH is set to 'both', any argument before '--' should target a valid Wrapper configuration property. 201:append 202set _PARAMETERS=%_PARAMETERS% %1 203shift 204goto parameters 205 206rem 207rem Run the Wrapper 208rem 209:callcommand 210if [%_PASS_THROUGH%]==[false] ( 211 %_WRAPPER_EXE% -c %_WRAPPER_CONF% 212) else ( 213 %_WRAPPER_EXE% -c %_WRAPPER_CONF% %_PARAMETERS% 214) 215if not errorlevel 1 goto :eof 216 217:preexitpause 218if %_WRAPPER_TIMEOUT% gtr 0 ( 219 timeout /t %_WRAPPER_TIMEOUT% 220) else ( 221 if %_WRAPPER_TIMEOUT% lss 0 ( 222 pause 223 ) 224) 225 226