/ Published in: DOS Batch
A DOS batch script to handle registering and controlling a JBoss service.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
@ECHO off SETLOCAL ENABLEDELAYEDEXPANSION CLS :: place this next to the run.bat in your JBoss distro and run it ECHO INFO: You may need to run this script as 'Administrator' user. ) ::------------------------------------------------------------------- :: Set TITLE, JBOSS_HOME, and DIRNAME variables ::------------------------------------------------------------------- ::------------------------------------------------------------------- :: Handle script args ::------------------------------------------------------------------- ::------------------------------------------------------------------- :: Parse first script argument for service action :: If no args are passed then prompt user ::------------------------------------------------------------------- :MAKECHOICE ECHO ----------------------------- ECHO Options menu: ECHO ----------------------------- ECHO [auto] Install and start service ECHO [install] Install service ECHO [start] Start service ECHO [stop] Stop service ECHO [remove] Remove or uninstall service ECHO [console] Run service as console ECHO [status] Query service status ECHO. ECHO Running silently since script has arguments. ) ECHO Empty answer. Try Again. GOTO :MAKECHOICE ) ECHO Choice fails without a second script argument passing service name. GOTO :END ) SET ACTION=Starting SET OPTION=-t GOTO :ACTIONSET ) ECHO Choice fails without a second script argument passing service name. GOTO :END ) SET ACTION=Installing SET OPTION=-i GOTO :ACTIONSET ) SET ACTION=Starting SET OPTION=-t GOTO :ACTIONSET ) SET ACTION=Stopping SET OPTION=-p GOTO :ACTIONSET ) SET ACTION=Uninstalling SET OPTION=-r GOTO :ACTIONSET ) SET ACTION=Console SET OPTION=-c GOTO :ACTIONSET ) SET ACTION=Querying SET OPTION=-q GOTO :ACTIONSET ) :ACTIONSET ::------------------------------------------------------------------- :: Set java options for wrapper :: Change back-slashes to forward-slashes before passing options to the wrapper ::------------------------------------------------------------------- ::------------------------------------------------------------------- :: Info output ::------------------------------------------------------------------- ECHO. ECHO. ::ECHO -- Before you install this service make sure that you properly configured the ::ECHO property called "wrapper.ntservice.account" in the wrapper config file. ::ECHO (It will default to running as the "Local System" user.) ECHO. ::------------------------------------------------------------------- :: Install service ::------------------------------------------------------------------- ECHO. DEL /Q servicename.txt ) :: when auto, perform 1 additional action ECHO. ECHO Registering service ... ECHO "%JAVA_HOME%\bin\java.exe" %WRAPPER_ARGS% -jar %JBOSS_HOME%\%APPDIR%\wrapper\wrapper.jar -i %WRAPPER_CONFIG_FILE% CALL "%JAVA_HOME%\bin\java.exe" %WRAPPER_ARGS% -jar %JBOSS_HOME%\%APPDIR%\wrapper\wrapper.jar -i %WRAPPER_CONFIG_FILE% CALL :WAIT ) ECHO. ECHO "%JAVA_HOME%\bin\java.exe" %WRAPPER_ARGS% -jar %JBOSS_HOME%\%APPDIR%\wrapper\wrapper.jar %OPTION% %WRAPPER_CONFIG_FILE% CALL "%JAVA_HOME%\bin\java.exe" %WRAPPER_ARGS% -jar %JBOSS_HOME%\%APPDIR%\wrapper\wrapper.jar %OPTION% %WRAPPER_CONFIG_FILE% ECHO. ECHO. ::------------------------------------------------------------------- :: Functions ::------------------------------------------------------------------- :GET_DIR EXIT /B 0 :WAIT PING.exe -n 6 -w 1 127.0.0.1>nul EXIT /B 0 ::------------------------------------------------------------------- :: End script ::------------------------------------------------------------------- :END
URL: https://gist.github.com/4271240