Index: main/trunk/greenstone2/gs2-web-server.bat
===================================================================
--- main/trunk/greenstone2/gs2-web-server.bat	(revision 23987)
+++ main/trunk/greenstone2/gs2-web-server.bat	(revision 24492)
@@ -190,47 +190,13 @@
 
 :: GLI launches gs2-server.bat with:
-:: cmd /c start "window" "c:\path to\gs2-server.bat" --config=c:\path to\glisite.cfg [--quit=portnum]
+:: cmd /c start "window" "c:\path to\gs2-web-server.bat" --config=c:\path to\glisite.cfg --quit=portnum --mode=gli
+:: where the --options are generally optional, but always used for GLI.
 :: The configfile param could contain spaces, in which case its space-separated parts spread over 
-:: multiple parameters . Need to handle things the following way, since using quotes to embed the 
-:: parameters breaks the start command, see http://ss64.com/nt/start.html
-:: This script is launched by the start cmd as:
-:: "c:\path to\gs2-server.bat" --config=c:\path to\config.cfg [--quit=portnum]. 
-:: But if the parameter  following --config=<some string> doesn't start with a double hyphen, we
-:: assume it to be part of the config parameter, as the configfile path may have contained spaces.
-
-:: Store all parameters together in config file var: we may or may not have a portnumber
-:: Get everything after the "--quitport=", if anything, and store it in port var.  If no port, nothing to do.
-set conf=%*
-if "%conf%" == "" goto :runit
-
-set port=%conf:*--quitport=%
-if "%conf%" == "%port%" (
-set port=
-goto :runit
-) else (
-set port=%port:~1%
-)
-
-:: Because we got here, need to adjust conf by removing " --quitport=" from it and prefixing this to port
-call set conf=%%conf:%port%=%%
-set conf=%conf:~0,-12%
-set port=--quitport=%port%
-
-:: Remove trailing spaces from conf and port
-:: (We'll put the all-important quotes around conf and port when the actual java cmd is launched)
-set tmp=%conf%
-call :trim %tmp%
-set conf=%tmp%
-set tmp=%port%
-call :trim %port%
-set port=%tmp%
-set tmp=
-
-goto :runit
-
-::  http://www.computing.net/answers/programming/dos-batch-remove-trailing-space/9270.html
-:trim
-set tmp=%*
-goto :eof
+:: multiple parameters. In the past, we used to handle this problem here. 
+:: At present we pass all the arguments as-is to the Server.jar program and let it handle the parameters.
+:: E.g. gs2-web-server.bat --config=C:\pinky was\here at greenstone2\glisite.cfg --mode=gli --quitport=50100
+:: or gs2-web-server.bat --quitport=50100 --config=C:\pinky was\here at greenstone2\glisite.cfg --mode=gli
+:: Note the (lack of) use of quotes!
+
 
 :runit 
@@ -242,15 +208,21 @@
 
 ::echo port: %port%& echo conf: %conf%& echo.& echo.
-:: "%JAVA_EXECUTABLE%" org.greenstone.server.Server2 "%GSDLHOME%" "%serverlang%" %*
-"%JAVA_EXECUTABLE%" org.greenstone.server.Server2 "%GSDLHOME%" "%serverlang%" "%conf%" "%port%"
-
-
-:: The 1st argument to gs2-server.bat (if any) would be --config, the 2nd is the config filename. 
-:: Both are stored in %conf% now. If the config file is glisite.cfg, then this script was launched through
-:: GLI and would have opened a DOS console. Need to exit from this script then to close the console.
-:: Remove --config=prefix and do a case insensitive comparison, since filepaths can have uppercase chars
-if "%conf%" == "" goto exit
-if /i "%conf:~9%" == "%GSDLHOME%\glisite.cfg" goto quitcmd
-goto exit
+:: Do not remove the quotes around %* !!! It's what helps Server2.jar deal with spaces in configfile path
+"%JAVA_EXECUTABLE%" org.greenstone.server.Server2 "%GSDLHOME%" "%serverlang%" "%*"
+
+
+:: All params are stored in %* now. This batch script can be called from the commandline or from GLI
+:: If the --mode(=gli) flag was passed in as parameter, then this script was launched through GLI
+:: and would have opened a DOS console. Need to then exit from this script to close the console.
+set allparams=%*
+:: And if there were absolutely no params to gs2-web-server.bat, it's not called from GLI either
+if "%allparams%" == "" goto exit
+set glimode=%allparams:--mode=%
+:: if one of the parameters was --mode(=gli), we close the console
+if /i "%allparams%" == "%glimode%" ( 
+	goto exit 
+) else ( 
+	goto quitcmd 
+)
 
 :: Exit the batch script (close the console)
