Index: main/trunk/gli/client-gli.bat
===================================================================
--- main/trunk/gli/client-gli.bat	(revision 24828)
+++ main/trunk/gli/client-gli.bat	(revision 24829)
@@ -1,3 +1,5 @@
 @echo off
+setlocal enabledelayedexpansion
+
 pushd "%CD%"
 CD /D "%~dp0"
@@ -94,5 +96,5 @@
 :: the client side. If we have Perl, pass in GSDLHOME for the -gsdl option and the PERLPATH.
 if "%PERLPATH%" == "" goto nogsdl
-	echo Perl and GSDLHOME (%GSDLHOME%) detected. Downloading is enabled.
+	echo Perl and GSDLHOME (!GSDLHOME!) detected. Downloading is enabled.
 	echo.
 	"%JAVA_EXECUTABLE%" -Xmx128M -cp classes/;GLI.jar;lib/apache.jar;lib/qfslib.jar org.greenstone.gatherer.GathererProg -use_remote_greenstone -gsdl "%GSDLHOME%" -perl "%PERLPATH%" %1 %2 %3 %4 %5 %6 %7 %8 %9
@@ -124,2 +126,3 @@
 set PROGABBR=
 popd
+endlocal
Index: main/trunk/gli/findjava.bat
===================================================================
--- main/trunk/gli/findjava.bat	(revision 24828)
+++ main/trunk/gli/findjava.bat	(revision 24829)
@@ -1,3 +1,4 @@
 @echo off
+setlocal enabledelayedexpansion
 
 :: Environment Variables passed in: _VERSION, GLILANG and possibly also
@@ -21,14 +22,14 @@
 	:: else we look for a compiled version of search4j in a GS installation
 	if "%_VERSION%" == "2" (
-		set SEARCH4J_EXECUTABLE=%GSDLHOME%\bin\windows\search4j.exe
-		set HINT=%GSDLHOME%\packages\jre
+		set SEARCH4J_EXECUTABLE=!GSDLHOME!\bin\windows\search4j.exe
+		set HINT=!GSDLHOME!\packages\jre
 	)
-    	if "%_VERSION%" == "3" (
-		set SEARCH4J_EXECUTABLE=%GSDL3SRCHOME%\bin\search4j.exe
-		set HINT=%GSDL3SRCHOME%\packages\jre
+	if "%_VERSION%" == "3" (
+		set SEARCH4J_EXECUTABLE=!GSDL3SRCHOME!\bin\search4j.exe
+		set HINT=!GSDL3SRCHOME!\packages\jre
 	)
 	if not exist "%SEARCH4J_EXECUTABLE%" goto tryJava
 
-:setJexec    
+:setJexec
     "%SEARCH4J_EXECUTABLE%" -e -m "%MIN_VERSION%" -p "%HINT%" | winutil\setvar.exe JAVA_EXECUTABLE > %TMP%\set_java_executable.bat
     call "%TMP%\set_java_executable.bat"
@@ -56,5 +57,5 @@
     		echo WARNING: 
 		echo Java Runtime not bundled with this Greenstone installation.
-		echo Using JAVA_HOME: %JAVA_HOME%
+		echo Using JAVA_HOME: !JAVA_HOME!
 		echo ^(NOTE: this needs to be %DISPLAY_MIN_VERSION% or higher.^)
 		echo ***************************************************************************
@@ -97,2 +98,4 @@
 set MIN_VERSION=
 set DISPLAY_MIN_VERSION=
+
+endlocal & set JAVA_EXECUTABLE=%JAVA_EXECUTABLE%& set GS_JAVA_HOME=%GS_JAVA_HOME%
Index: main/trunk/gli/gli.bat
===================================================================
--- main/trunk/gli/gli.bat	(revision 24828)
+++ main/trunk/gli/gli.bat	(revision 24829)
@@ -1,3 +1,5 @@
 @echo off
+setlocal enabledelayedexpansion
+
 color 0A
 set startdir=%CD%
@@ -48,9 +50,9 @@
 	echo.
 	echo Checking if the Greenstone collection directory is writable ...
-	(echo This is a temporary file. It is safe to delete it. > "%GSDLHOME%\collect\testing.tmp" ) 2>nul
+	(echo This is a temporary file. It is safe to delete it. > "!GSDLHOME!\collect\testing.tmp" ) 2>nul
 	if exist "%GSDLHOME%\collect\testing.tmp" goto deleteTempFile 
 	if "%1" == "Elevated" goto printWarning
 	echo ... FAILED
-	echo The %PROGNAME% cannot write to the collection directory (%GSDLHOME%\collect)
+	echo The %PROGNAME% cannot write to the collection directory (!GSDLHOME!\collect)
 	echo Requesting elevated status to become admin user to continue.
 	"%GSDLHOME%\bin\windows\gstart.exe" %0 Elevated %1 %2 %3 %4 %5 %6 %7 %8 %9
@@ -59,5 +61,5 @@
 :printWarning
 	echo ... FAILED
-	echo The %PROGNAME% cannot write to the log directory (%GSDLHOME%\collect). 
+	echo The %PROGNAME% cannot write to the log directory (!GSDLHOME!\collect). 
 	echo Attempting to continue without permissions.
 	goto shiftElevated
@@ -114,5 +116,5 @@
 if not "%GSDL3SRCHOME%" == "" (
     echo GSDL3SRCHOME:
-    echo %GSDL3SRCHOME%
+    echo !GSDL3SRCHOME!
 	echo.
 )
@@ -120,5 +122,5 @@
 if not "%GSDL3HOME%" == "" (
     echo GSDL3HOME:
-    echo %GSDL3HOME%
+    echo !GSDL3HOME!
 	echo.
 )
@@ -126,5 +128,5 @@
 if not "%GSDLHOME%" == "" (
     echo GSDLHOME:
-    echo %GSDLHOME%
+    echo !GSDLHOME!
 	echo.
 )
@@ -166,7 +168,7 @@
 :localLib
     if exist "%GSDLHOME%\server.exe" (
-	set locallib=%GSDLHOME%\server.exe
+	set locallib=!GSDLHOME!\server.exe
     ) else (
-	set locallib=%GSDLHOME%\gs2-web-server.bat
+	set locallib=!GSDLHOME!\gs2-web-server.bat
     )
 
@@ -211,2 +213,4 @@
 cd "%startdir%"
 set startdir=
+
+endlocal
Index: main/trunk/gli/makejar.bat
===================================================================
--- main/trunk/gli/makejar.bat	(revision 24828)
+++ main/trunk/gli/makejar.bat	(revision 24829)
@@ -1,3 +1,5 @@
 echo off
+setlocal enabledelayedexpansion
+
 pushd "%CD%"
 CD /D "%~dp0"
@@ -115,6 +117,6 @@
 
   cd jar
-  "%JARPATH%\jar" xf ..\lib\apache.jar com org
-  "%JARPATH%\jar" xf ..\lib\qfslib.jar de
+  "!JARPATH!\jar" xf ..\lib\apache.jar com org
+  "!JARPATH!\jar" xf ..\lib\qfslib.jar de
 
   cd ..
@@ -152,5 +154,5 @@
 
     if not exist appletstore (
-      "%JARPATH%\keytool" -genkey -alias privateKey -keystore appletstore -storepass greenstone
+      "!JARPATH!\keytool" -genkey -alias privateKey -keystore appletstore -storepass greenstone
     )
 
@@ -158,8 +160,8 @@
     if exist appletpasswd (
       echo Using jarsigner to make signed jar file ...
-      "%JARPATH%\jarsigner" -keystore appletstore -signedjar SignedGatherer.jar GLI.jar privateKey < appletpasswd >NUL 2>NUL
+      "!JARPATH!\jarsigner" -keystore appletstore -signedjar SignedGatherer.jar GLI.jar privateKey < appletpasswd >NUL 2>NUL
       echo ... done.
     ) ELSE (
-      "%JARPATH%\jarsigner" -keystore appletstore -signedjar SignedGatherer.jar GLI.jar privateKey
+      "!JARPATH!\jarsigner" -keystore appletstore -signedjar SignedGatherer.jar GLI.jar privateKey
     )
     echo Installing SignedGatherer in ..\bin\java
@@ -169,2 +171,3 @@
 
 popd
+endlocal
