anchor.diff:    set PRUNSRV="%JBOSS_HOME%\bin\service\wildfly-service"
   )
   
  -setlocal DisableDelayedExpansion
  -
  -if /I "%1" == "install"   goto cmdInstall
  -if /I "%1" == "uninstall" goto cmdUninstall
  -if /I "%1" == "start"     goto cmdStart
  -if /I "%1" == "stop"      goto cmdStop
  -if /I "%1" == "restart"   goto cmdRestart
  -
  -:cmdUsage
  -echo Usage:
  -echo   service install [/controller localhost:9990] [/loglevel INFO] [/host [domainhost]] [/user username /password password] 
  -echo   service uninstall
  -echo   service start
  -echo   service stop
  -echo   service restart
  -echo(
  -echo The options for "service install":
  -echo   /controller        : the host:port of the domain controller, default: 127.0.0.1:9990
  -echo   /loglevel          : the log level for the service:  Error, Info, Warn or Debug ^(Case insensitive^), default: INFO 
  -echo   /host [domainhost] : indicated domain mode is to be used with an optional domain controller name, default: master
  -echo                        Not specifying /host will install in standalone mode
  -echo   /user              : username for the shutdown command
  -echo   /password          : password for the shutdown command
  -echo(
  -goto endBatch
  -
  -:cmdInstall
  -shift
  -
  +if "%DEBUG%" == "1" (
  +	echo PRUNSRV %PRUNSRV%
  +)
  +
  +echo(
  +
  +rem defaults
  +set SHORTNAME=Wildfly
  +set DISPLAYNAME=WildFly
  +rem NO quotes around the description here !
  +set DESCRIPTION="WildFly Application Server"
   set CONTROLLER=localhost:9990
   set DC_HOST=master
   set IS_DOMAIN=false
   set LOGLEVEL=INFO
  +set LOGPATH=
   set JBOSSUSER=
  -set PASSWORD=
  +set JBOSSPASS=
  +set SERVICE_USER=
  +set SERVICE_PASS=
  +set STARTUP_MODE=manual
  +set ISDEBUG=
  +set CONFIG=
  +set HOSTCONFIG=host.xml
  +set BASE=
  +
  +set COMMAND=%1
  +shift
  +if /I "%COMMAND%" == "install"   goto cmdInstall
  +if /I "%COMMAND%" == "uninstall" goto cmdUninstall
  +if /I "%COMMAND%" == "start"     goto cmdStart
  +if /I "%COMMAND%" == "stop"      goto cmdStop
  +if /I "%COMMAND%" == "restart"   goto cmdRestart
  +
  +echo ERROR: invalid command
  +
  +:cmdUsage
  +echo WildFly Service Script for Windows
  +echo Usage:
  +echo(
  +echo   service install ^<options^>  , where the options are:
  +echo(
  +echo     /startup                  : Set the service to auto start
  +echo                                 Not specifying sets the service to manual
  +echo(
  +echo     /jbossuser ^<username^>     : JBoss username to use for the shutdown command.
  +echo     /jbosspass ^<password^>     : Password for /jbossuser
  +echo(
  +echo     /controller ^<host:port^>   : The host:port of the management interface.
  +echo                                 default: %CONTROLLER%
  +echo(
  +echo     /host [^<domainhost^>]      : Indicates that domain mode is to be used with an
  +echo                                 optional domain controller name.
  +echo                                 default: %DC_HOST%
  +echo                                 Not specifying /host will install JBoss in
  +echo                                 standalone mode.
  +echo(
  +echo Options to use when multiple services or different accounts are needed:
  +echo(
  +echo     /name ^<servicename^>       : The name of the service
  +echo(
  +echo                                 default: %SHORTNAME%
  +echo     /desc ^<description^>       : The description of the service, use double
  +echo                                 quotes to allow spaces.
  +echo                                 Maximum 1024 characters.
  +echo                                 default: %DESCRIPTION%
  +echo(
  +echo     /serviceuser ^<username^>   : Specifies the name of the account under which
  +echo                                 the service should run.
  +echo                                 Use an account name in the form of
  +echo                                 DomainName\UserName
  +echo                                 default: not used, the service runs as
  +echo                                 Local System Account.
  +echo     /servicepass ^<password^>   : password for /serviceuser
  +echo(
  +echo Advanced options:
  +echo(
  +echo     /config ^<xmlfile^>         : The server-config to use
  +echo                                 default: standalone.xml / domain.xml
  +echo     /hostconfig ^<xmlfile^>     : domain mode only, the host config to use
  +echo                                 default: host.xml
  +echo(
  +echo     /base ^<directory^>         : The base directory for server/domain content
  +echo                                 Must be specified as a fully qualified path
  +echo                                 default: %JBOSS_HOME%\standalone or
  +echo                                          %JBOSS_HOME%\domain
  +echo(
  +echo     /loglevel ^<level^>         : The log level for the service:  Error, Info,
  +echo                                 Warn or Debug ^(Case insensitive^)
  +echo                                 default: %LOGLEVEL%
  +echo     /logpath ^<path^>           : Path of the log
  +echo                                 default depends on domain or standalone mode
  +echo                                 /base applies when /logpath is not set.
  +echo                                   %JBOSS_HOME%\domain\log
  +echo                                   %JBOSS_HOME%\standalone\log
  +echo(
  +echo     /debug                    : run the service install in debug mode
  +echo(
  +echo Other commands:
  +echo(
  +echo   service uninstall [/name ^<servicename^>]
  +echo   service start [/name ^<servicename^>]
  +echo   service stop [/name ^<servicename^>]
  +echo   service restart [/name ^<servicename^>]
  +echo(
  +echo     /name  ^<servicename^>      : Name of the service: should not contain spaces
  +echo                                 default: %SHORTNAME%
  +echo(
  +goto endBatch
  +
  +:cmdInstall
   
   :LoopArgs
  -if "%1"=="" goto doInstall
  -
  -if /I "%1"=="/controller" (
  -  if not "%2"=="" (
  -    rem should really check if the format is acceptable
  -    set CONTROLLER=%2
  -  ) else (
  -    echo ERROR: A controller url should be specified in the format host:port, example:  127.0.0.1:9990
  -    goto endBatch
  -  )
  -  shift
  -  shift
  -  goto LoopArgs
  -)
  -if /I "%1"=="/user" (
  -  if not "%2"=="" (
  -    set JBOSSUSER=%2
  -  ) else (
  +if "%~1" == "" goto doInstall
  +
  +if /I "%~1"== "/debug" (
  +  set ISDEBUG=true
  +  shift
  +  goto LoopArgs
  +)
  +if /I "%~1"== "/startup" (
  +  set STARTUP_MODE=auto
  +  shift
  +  goto LoopArgs
  +)
  +if /I "%~1"== "/config" (
  +  set CONFIG=
  +  if not "%~2"=="" (
  +    set T=%~2
  +    if not "!T:~0,1!"=="/" (
  +      set CONFIG=%~2
  +    )
  +  )
  +  if "!CONFIG!" == "" (
  +    echo ERROR: You need to specify a config name
  +    goto endBatch
  +  )
  +  shift
  +  shift
  +  goto LoopArgs
  +)
  +if /I "%~1"== "/hostconfig" (
  +  set HOSTCONFIG=
  +  if not "%~2"=="" (
  +    set T=%~2
  +    if not "!T:~0,1!"=="/" (
  +      set HOSTCONFIG=%~2
  +    )
  +  )
  +  if "!HOSTCONFIG!" == "" (
  +    echo ERROR: You need to specify a host-config name
  +    goto endBatch
  +  )
  +  shift
  +  shift
  +  goto LoopArgs
  +)
  +if /I "%~1"== "/base" (
  +  set BASE=
  +  if not "%~2"=="" (
  +    set T=%~2
  +    if not "!T:~0,1!"=="/" (
  +      set BASE=%~2
  +    )
  +  )
  +  if "!BASE!" == "" (
  +    echo ERROR: You need to specify a base directory name
  +    goto endBatch
  +  )
  +  shift
  +  shift
  +  goto LoopArgs
  +)
  +if /I "%~1"== "/controller" (
  +  set CONTROLLER=
  +  if not "%~2"=="" (
  +    set T=%~2
  +    if not "!T:~0,1!"=="/" (
  +      set CONTROLLER=%~2
  +    )
  +  )
  +  if "!CONTROLLER!" == "" (
  +    echo ERROR: The management interface should be specified in the format host:port, example:  127.0.0.1:9999
  +    goto endBatch
  +  )
  +  shift
  +  shift
  +  goto LoopArgs
  +)
  +if /I "%~1"== "/name" (
  +  set SHORTNAME=
  +  if not "%~2"=="" (
  +    set T=%~2
  +    if not "!T:~0,1!"=="/" (
  +      set SHORTNAME=%~2
  +      set DISPLAYNAME=%~2
  +    )
  +  )
  +  if "!SHORTNAME!" == "" (
  +    echo ERROR: You need to specify a service name
  +    goto endBatch
  +  )
  +  shift
  +  shift
  +  goto LoopArgs
  +)
  +if /I "%~1"== "/desc" (
  +  set DESCRIPTION=
  +  if not "%~2"=="" (
  +    set T=%~2
  +    if not "!T:~0,1!"=="/" (
  +      set DESCRIPTION=%~2
  +    )
  +  )
  +  if "!DESCRIPTION!" == "" (
  +    echo ERROR: You need to specify a description, maximum of 1024 characters
  +    goto endBatch
  +  )
  +  shift
  +  shift
  +  goto LoopArgs
  +)
  +if /I "%~1"== "/jbossuser" (
  +  set JBOSSUSER=
  +  if not "%~2"=="" (
  +    set T=%~2
  +    if not "!T:~0,1!"=="/" (
  +      set JBOSSUSER=%~2
  +    )
  +  )
  +  if "!JBOSSUSER!" == "" (
       echo ERROR: You need to specify a username
       goto endBatch
     )
  
positive.code: :doInstall
  set CREDENTIALS=
  if not "%JBOSSUSER%" == "" (
    if "%PASSWORD%" =="" (
      echo When specifying a user, you need to specify the password
      goto endBatch
    )
    set CREDENTIALS=--user=%JBOSSUSER% --password=%PASSWORD%
  )
  if /I "%IS_DOMAIN%" == "true" (
    set STARTPARAM="/c \"set NOPAUSE=Y ^^^&^^^& domain.bat\""
    set STOPPARAM="/c jboss-cli.bat --controller=%CONTROLLER% --connect %CREDENTIALS% --command=/host=!DC_HOST!:shutdown"
    set LOGPATH="%JBOSS_HOME%\domain\log"
  ) else (
    set STARTPARAM="/c \"set NOPAUSE=Y ^^^&^^^& standalone.bat\""
    set STOPPARAM="/c \"set NOPAUSE=Y ^^^&^^^& jboss-cli.bat --controller=%CONTROLLER% --connect %CREDENTIALS% --command=:shutdown\""
    set LOGPATH="%JBOSS_HOME%\standalone\log"
  )
  
  rem echo %STARTPARAM%
  rem echo %STOPPARAM%
  rem echo %LOGLEVEL%
  rem goto endBatch
  
  %PRUNSRV% install %SHORTNAME% --DisplayName=%DISPLAYNAME% --Description %DESCRIPTION% --LogLevel=%LOGLEVEL% --LogPath=%LOGPATH% --LogPrefix=service --StdOutput=auto --StdError=auto --StartMode=exe --StartImage=cmd.exe --StartPath="%JBOSS_HOME%\bin" ++StartParams=%STARTPARAM% --StopMode=exe --StopImage=cmd.exe --StopPath="%JBOSS_HOME%\bin" ++StopParams=%STOPPARAM%
  goto cmdEnd
  
  :cmdUninstall
  %PRUNSRV% stop %SHORTNAME%
  if "%errorlevel%" == "0" (
    %PRUNSRV% delete %SHORTNAME%
  ) else (
    echo Unable to stop the service
  )
  goto cmdEnd
  
  :cmdStart
  %PRUNSRV% start %SHORTNAME%
  goto cmdEnd
  
  :cmdStop
  %PRUNSRV% stop %SHORTNAME%
  goto cmdEnd
  
  :cmdRestart
  %PRUNSRV% stop %SHORTNAME%
  if "%errorlevel%" == "0" (
    %PRUNSRV% start %SHORTNAME%
  ) else (
    echo Unable to stop the service
  )
  goto cmdEnd
  
  :cmdEnd
  REM need to add other error messages (list higher nr first !)
  if errorlevel 8 (
    echo ERROR: The service %SHORTNAME% already exists
    goto endBatch
  )
  if errorlevel 2 (
    echo ERROR: Failed to load service configuration
    goto endBatch
  )
  if errorlevel 0 (
    echo Success
    goto endBatch
  )
  echo errorlevel=%errorlevel%
  
  rem nothing below, exit
  :endBatch
  
negative.code: @echo off
  
  REM -------------------------------------------------------------------------
  REM  WildFly Service Script for Windows
  REM    It has to reside in %JBOSS_HOME%\bin
  REM    It is expecting that prunsrv.exe reside in:
  REM      %JBOSS_HOME%\bin\service\
  REM Easiest way to make it work is to copy whole "service" directory to %JBOSS_HOME%\bin
  REM
  REM  v9 2016-02-16 customize for WildFly, fix working on paths with spaces (Tomaz Cerar)
  REM  v8 2016-01-20 customize for EAP 7 (Petr Sakar)
  REM  v7 2014-07-09 added /logpath /startup /config /hostconfig /base /debug
  REM                      simplified/corrected use of quotes
  REM
  REM  v6 was shipped with EAP 6.2.0 and supports all previous versions of 6.x as well.
  REM  v6 2013-08-21 added /name /desc
  REM                added /serviceuser /servicepass
  REM                extended directory checking for versions and locations
  REM                extended checking on option usage
  REM  v5	2013-06-10 adapted for EAP 6.1.0
  REM  v4	2012-10-03 Small changes to properly handles spaces in LogPath, StartPath,
  REM                and StopPath (George Rypysc)
  REM  v3	2012-09-14 fixed service log path
  REM                cmd line options for controller,domain host, loglevel,
  REM		   username,password
  REM  v2	2012-09-05 NOPAUSE support
  REM  v1	2012-08-20 initial edit
  REM
  REM Author: Tom Fonteyne (unless noted above)
  REM ========================================================
  setlocal EnableExtensions EnableDelayedExpansion
  
  set DEBUG=0
  if "%DEBUG%" == "1" (
  	echo "Debug info enabled"
  	echo on
  )
  
  set "DIRNAME=%~dp0%"
  if "%DEBUG%" == "1" (
  	echo DIRNAME "%DIRNAME%x"
  )
  
  if exist "%DIRNAME%..\jboss-modules.jar" (
    REM we are in JBOSS_HOME/bin
    set "WE=%DIRNAME%..\"
    goto :WE_FOUND
  ) else if exist "%DIRNAME%..\..\jboss-modules.jar" (
    REM we are in bin\service in a WildFly installation
    set "WE=%DIRNAME%..\..\"
    goto :WE_FOUND
  ) else if exist "%DIRNAME%..\..\..\jboss-modules.jar" (
    REM we are in sbin in a 6.0.x installation
    set "WE=%DIRNAME%..\..\..\"
    goto :WE_FOUND
  ) else (
    REM we should be in sbin in 6.1 and up
    set "WE=%DIRNAME%..\..\..\..\..\..\"
  )
  
  if "%DEBUG%" == "1" (
  	echo WE was not found, using "%WE%"
  )
  
  :WE_FOUND
  if "%DEBUG%" == "1" (
  	echo WE "%WE%"
  )
  pushd "%WE%"
  set "RESOLVED_JBOSS_HOME=%CD%"
  popd
  set WE=
  set DIRNAME=
  if "x%JBOSS_HOME%" == "x" (
    set "JBOSS_HOME=%RESOLVED_JBOSS_HOME%"
  )
  
  pushd "%JBOSS_HOME%"
  set "SANITIZED_JBOSS_HOME=%CD%"
  popd
  
  if "%DEBUG%" == "1" (
  	echo SANITIZED_JBOSS_HOME="%SANITIZED_JBOSS_HOME%"
  	echo RESOLVED_JBOSS_HOME="%RESOLVED_JBOSS_HOME%"
  	echo JBOSS_HOME="%JBOSS_HOME%"
  )
  
  if not "%RESOLVED_JBOSS_HOME%x" == "%SANITIZED_JBOSS_HOME%x" (
      echo WARNING JBOSS_HOME may be pointing to a different installation - unpredictable results may occur.
      goto cmdEnd
  )
  
  rem Find jboss-modules.jar to check JBOSS_HOME
  if not exist "%JBOSS_HOME%\jboss-modules.jar" (
    echo Could not locate "%JBOSS_HOME%\jboss-modules.jar"
    goto cmdEnd
  )
  
  set PRUNSRV=
  if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
    echo Using the X86-64bit version of prunsrv
    set PRUNSRV="%JBOSS_HOME%\bin\service\amd64\wildfly-service"
  