To run your application as a console app, execute the following command.
C:\MyApp\bin> Wrapper.exe -c C:\MyApp\conf\wrapper.conf
|
To install the application as an NT service, execute.
C:\MyApp\bin> Wrapper.exe -i C:\MyApp\conf\wrapper.conf
|
Then to start it, either reboot, go to the services control panel, or execute:
C:\MyApp\bin> net start MyApp
|
To uninstall the application as an NT service, execute:
C:\MyApp\bin> Wrapper.exe -r C:\MyApp\conf\wrapper.conf
|
These commands should normally be placed in batch files in the application's bin
directory to make them easier to use.
A typical application would have the following three batch files in the bin
directory with the Wrapper.exe file. The scripts will look for a wrapper.conf
file passed in as an argument and then use a default if one is not specified.
These examples assume that the '@app.home@' token will be replaced with your
application's home directory on installation. Something like 'C:\MyApp'. The
quotes around the paths in the scripts make it possible for the path to contain
spaces.
MyApp.bat
@echo off
set _WRAPPER_CONF="%~f1"
if not %_WRAPPER_CONF%=="" goto startup
set _WRAPPER_CONF="@app.home@\conf\wrapper.conf"
:startup
"@app.home@\bin\Wrapper.exe" -c %_WRAPPER_CONF%
if not errorlevel 1 goto end
pause
:end
set _WRAPPER_CONF=
|
InstallMyApp-NT.bat
@echo off
set _WRAPPER_CONF="%~f1"
if not %_WRAPPER_CONF%=="" goto startup
set _WRAPPER_CONF="@app.home@\conf\wrapper.conf"
:startup
"@app.home@\bin\Wrapper.exe" -i %_WRAPPER_CONF%
if not errorlevel 1 goto end
pause
:end
set _WRAPPER_CONF=
|
UninstallMyApp-NT.bat
@echo off
set _WRAPPER_CONF="%~f1"
if not %_WRAPPER_CONF%=="" goto startup
set _WRAPPER_CONF="@app.home@\conf\wrapper.conf"
:startup
"@app.home@\bin\Wrapper.exe" -r %_WRAPPER_CONF%
if not errorlevel 1 goto end
pause
:end
set _WRAPPER_CONF=
|
It is also possible to make batch scripts which use only relative paths. This has
the benefit of allowing you to unzip an application and run it in any location, but
it has the drawback that the script will not work correctly on older version of
windows. Template batch files can be found in the src/bin directory, named
App.bat.in, InstallApp-NT.bat.in and UninstallApp-NT.bat.in. They should be
renamed to match the name of your application.
MyApp.bat
@echo off
rem
rem Find the application home.
rem
if "%OS%"=="Windows_NT" goto nt
echo This is not NT, so please edit this script and set _APP_HOME manually
set _APP_HOME=..
goto conf
:nt
rem %~dp0 is name of current script under NT
set _APP_HOME=%~dp0
rem : operator works similar to make : operator
set _APP_HOME=%_APP_HOME:\bin\=%
rem
rem Find the wrapper.conf
rem
:conf
set _WRAPPER_CONF="%~f1"
if not %_WRAPPER_CONF%=="" goto startup
set _WRAPPER_CONF="%_APP_HOME%\conf\wrapper.conf"
rem
rem Run the application.
rem At runtime, the current directory will be that of Wrapper.exe
rem
:startup
"%_APP_HOME%\bin\Wrapper.exe" -c %_WRAPPER_CONF%
if not errorlevel 1 goto end
pause
:end
set _APP_HOME=
set _WRAPPER_CONF=
|
Starting in version 2.2.3, it is possible to specify paths in your wrapper.conf
file which are relative to the Wrapper.exe file. Older versions did not work
correctly with relative paths when the application was run as an NT service.