anchor.diff:    shift
     goto LoopArgs
   )
  -if /I "%1"=="/password" (
  -  if not "%2"=="" (
  -    set PASSWORD=%2
  -  ) else (
  -    echo ERROR: You need to specify a password
  -    goto endBatch
  -  )
  -  shift
  -  shift
  -  goto LoopArgs
  -)
  -if /I "%1"=="/host" (
  +if /I "%~1"== "/jbosspass" (
  +  set JBOSSPASS=
  +  if not "%~2"=="" (
  +    set T=%~2
  +    if not "!T:~0,1!"=="/" (
  +      set JBOSSPASS=%~2
  +    )
  +  )
  +  if "!JBOSSPASS!" == "" (
  +    echo ERROR: You need to specify a password for /jbosspass
  +    goto endBatch
  +  )
  +  shift
  +  shift
  +  goto LoopArgs
  +)
  +if /I "%~1"== "/serviceuser" (
  +  set SERVICE_USER=
  +  if not "%~2"=="" (
  +    set T=%~2
  +    if not "!T:~0,1!"=="/" (
  +      set SERVICE_USER=%~2
  +    )
  +  )
  +  if "!SERVICE_USER!" == "" (
  +    echo ERROR: You need to specify a username in the format DOMAIN\USER, or .\USER for the local domain
  +    goto endBatch
  +  )
  +  shift
  +  shift
  +  goto LoopArgs
  +)
  +if /I "%~1"== "/servicepass" (
  +  set SERVICE_PASS=
  +  if not "%~2"=="" (
  +    set T=%~2
  +    if not "!T:~0,1!"=="/" (
  +      set SERVICE_PASS=%~2
  +    )
  +  )
  +  if "!SERVICE_PASS!" == "" (
  +    echo ERROR: You need to specify a password for /servicepass
  +    goto endBatch
  +  )
  +  shift
  +  shift
  +  goto LoopArgs
  +)
  +rem the hostname is optional
  +if /I "%~1"== "/host" (
     set IS_DOMAIN=true
  -  if not "%2"=="" (
  -    set T=%2
  -    if not "!T:~0,1!"=="/" (
  -      set DC_HOST=!T!
  +  if not "%~2"=="" (
  +    set T=%~2
  +    if not "!T:~0,1!"=="/" (
  +      set DC_HOST=%~2
         shift
       )
     )
     shift
     goto LoopArgs
   )
  -if /I "%1"=="/loglevel" (
  -  if /I not "%2"=="Error" if /I not "%2"=="Info" if /I not "%2"=="Warn" if /I not "%2"=="Debug" (
  +if /I "%~1"== "/loglevel" (
  +  if /I not "%~2"=="Error" if /I not "%~2"=="Info" if /I not "%~2"=="Warn" if /I not "%~2"=="Debug" (
       echo ERROR: /loglevel must be set to Error, Info, Warn or Debug ^(Case insensitive^)
  -    goto endBatch      
  -  )
  -  set LOGLEVEL=%2
  +    goto endBatch
  +  )
  +  set LOGLEVEL=%~2
  +  shift
  +  shift
  +  goto LoopArgs
  +)
  +if /I "%~1"== "/logpath" (
  +  set LOGPATH=
  +  if not "%~2"=="" (
  +    set T=%~2
  +    if not "!T:~0,1!"=="/" (
  +      set LOGPATH=%~2
  +	)
  +  )
  +  if "!LOGPATH!" == "" (
  +    echo ERROR: You need to specify a path for the service log
  +    goto endBatch
  +  )
     shift
     shift
     goto LoopArgs
  
positive.code: @echo off
  setlocal EnableExtensions EnableDelayedExpansion
  REM -------------------------------------------------------------------------
  REM  Red Hat - JBoss EAP 6 Service Script for Windows
  REM            It has to reside in modules\native\sbin\
  REM
  REM  2013-07-01 Minor changes to make it work with Wildfly
  REM  2012-09-14 fixed service log path
  REM             cmd line options for controller,domain host, loglevel,
  REM		username,password
  REM  2012-09-05 NOPAUSE support
  REM  2012-08-20 initial edit
  REM
  REM Author: Tom Fonteyne
  REM
  REM ==================================================================
  REM If more then one service is needed, copy this file to another name
  REM and use unique names for SHORTNAME, DISPLAYNAME, DESCRIPTION
  REM ==================================================================
  set SHORTNAME=Wildfly
  set DISPLAYNAME="Wildfly"
  set DESCRIPTION="Wildfly Application Server"
  REM ========================================================
  
  set "DIRNAME=%~dp0%"
  cd > nul
  pushd %DIRNAME%..\..
  set "RESOLVED_JBOSS_HOME=%CD%"
  popd
  set DIRNAME=
  
  if "x%JBOSS_HOME%" == "x" (
    set "JBOSS_HOME=%RESOLVED_JBOSS_HOME%" 
  )
  
  pushd "%JBOSS_HOME%"
  set "SANITIZED_JBOSS_HOME=%CD%"
  popd
  
  if "%RESOLVED_JBOSS_HOME%" NEQ "%SANITIZED_JBOSS_HOME%" (
      echo WARNING JBOSS_HOME may be pointing to a different installation - unpredictable results may occur.
      echo Please check that this script is located in the bin\services\ directory.
      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".
    echo Please check that this script is located in the bin\services\ directory.
    goto cmdEnd
  )
  
  if "x%JAVA_HOME%" == "x" (
    echo JAVA_HOME is not set.
    echo Set JAVA_HOME to the directory of your local JDK to avoid this message.
    goto cmdEnd
  )
  
  if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
    echo Using the X86-64bit version of prunsrv
    set PRUNSRV="%JBOSS_HOME%\bin\service\amd64\wildfly-service"
  
negative.code:   set PRUNSRV="%JBOSS_HOME%\bin\service\wildfly-service"
  )
  
  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 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"== "/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
    )
  