Index: /greenstone3/trunk/gs3-setup.bat
===================================================================
--- /greenstone3/trunk/gs3-setup.bat	(revision 15070)
+++ /greenstone3/trunk/gs3-setup.bat	(revision 15071)
@@ -1,8 +1,5 @@
 @echo off
 
-::get user defined environment variable
-set JRE_HOME=
-set JAVA_HOME=
-set CLASSPATH=
+if exist machine.bat call machine.bat
 
 if exist gs3-setup.bat goto start
@@ -12,10 +9,8 @@
 :start
 :: ---- Set the GSDL3HOME variable to the current directory ----
-cd | winutil\setvar.exe GSDL3SRCHOME > setgsdl3.bat
-call setgsdl3.bat
-del setgsdl3.bat
-echo GSDL3SRCHOME: %GSDL3SRCHOME%
+cd | winutil\setvar.exe GSDL3SRCHOME > %SystemRoot%\Temp\setgsdl3.bat
+call %SystemRoot%\Temp\setgsdl3.bat
+del %SystemRoot%\Temp\setgsdl3.bat
 set GSDL3HOME=%GSDL3SRCHOME%\web
-echo GSDL3HOME: %GSDL3HOME%
 
 :: change if using external tomcat
@@ -27,138 +22,27 @@
 
 :: ---- Set the CLASSPATH environment variable ----
+if "%GS_CP_SET%" == "yes" goto skipSetCp
 set CLASSPATH=.;%GSDL3HOME%\WEB-INF\classes;%GSDL3SRCHOME%\resources\java;%CLASSPATH%
-if exist setcp.bat del setcp.bat
-for %%j in ("%GSDL3SRCHOME%"\*.jar) do echo set CLASSPATH=%%CLASSPATH%%;%%j>> setcp.bat
-for %%j in ("%GSDL3HOME%"\WEB-INF\lib\*.jar) do echo set CLASSPATH=%%CLASSPATH%%;%%j>> setcp.bat
-for %%j in ("%GSDL3SRCHOME%"\lib\jni\*.jar) do echo set CLASSPATH=%%CLASSPATH%%;%%j>> setcp.bat
-for %%j in ("%TOMCAT_HOME%"\common\endorsed\*.jar) do echo set CLASSPATH=%%CLASSPATH%%;%%j>> setcp.bat
-for %%j in ("%GSDL3SRCHOME%"\build\*.jar) do echo set CLASSPATH=%%CLASSPATH%%;%%j>> setcp.bat
+if exist %SystemRoot%\Temp\setcp.bat del %SystemRoot%\Temp\setcp.bat
+for %%j in ("%GSDL3SRCHOME%"\*.jar) do echo set CLASSPATH=%%CLASSPATH%%;%%j>> %SystemRoot%\Temp\setcp.bat
+for %%j in ("%GSDL3HOME%"\WEB-INF\lib\*.jar) do echo set CLASSPATH=%%CLASSPATH%%;%%j>> %SystemRoot%\Temp\setcp.bat
+for %%j in ("%GSDL3SRCHOME%"\lib\jni\*.jar) do echo set CLASSPATH=%%CLASSPATH%%;%%j>> %SystemRoot%\Temp\setcp.bat
+for %%j in ("%TOMCAT_HOME%"\common\endorsed\*.jar) do echo set CLASSPATH=%%CLASSPATH%%;%%j>> %SystemRoot%\Temp\setcp.bat
+for %%j in ("%GSDL3SRCHOME%"\build\*.jar) do echo set CLASSPATH=%%CLASSPATH%%;%%j>> %SystemRoot%\Temp\setcp.bat
+call %SystemRoot%\Temp\setcp.bat
+del %SystemRoot%\Temp\setcp.bat
+:skipSetCp
 
-call setcp.bat
-del setcp.bat
+winutil\launcher.exe -find | winutil\setvar.exe _JRE_HOME > %SystemRoot%\Temp\set_jre_home.bat
+call %SystemRoot%\Temp\set_jre_home.bat
+del %SystemRoot%\Temp\set_jre_home.bat
 
-goto findJREHOME
+echo %_JRE_HOME%\bin\java.exe | winutil\setvar.exe RUNJAVA > %SystemRoot%\Temp\setrunjava.bat
+call %SystemRoot%\Temp\setrunjava.bat
+del %SystemRoot%\Temp\setrunjava.bat
 
-:: ---- Check JRE_HOME ----
-:findJREHOME
-if not "%JRE_HOME%" == "" goto testJREHOME 
-   goto findJREHOME2 	 
+if "%JRE_HOME%" == "" set JRE_HOME=%_JRE_HOME%
 
-::---- try JREHOME ----
-:findJREHOME2 
-if "%JREHOME%" == "" goto findJAVAHOME  
-   set JRE_HOME=%JREHOME%
-   testJREHOME
-
-::test JRE_HOME is set correctly
-:testJREHOME 
-if exist "%JRE_HOME%\bin\java.exe" goto gotJREHOME
-   echo JRE_HOME: "%JRE_HOME%" 	
-   echo Couldn't find "%JRE_HOME%\bin\java.exe"	
-   echo The JRE_HOME environment variable is not defined correctly
-   echo This environment variable is needed to run this program
-   goto pauseANdExit  	
-
-
-::set the RUNJAVA and exit
-:gotJREHOME
- set RUNJAVA=%JRE_HOME%\bin\java.exe
- set PATH=%JRE_HOME%\bin;%PATH%
- echo JRE_HOME: "%JRE_HOME%"
- echo Your environment has successfully been set up to run Greenstone3
- goto exit
-
-
-:: ---- check JAVA_HOME ----
-:findJAVAHOME
-if not "%JAVA_HOME%" == "" goto testJAVAHOME
-   goto findJAVAHOME2
-
- 
-::---- check JAVAHOME ----
-:findJAVAHOME2 
-if "%JAVAHOME%" == "" goto noJAVAHOME  
-   set JAVA_HOME=%JAVAHOME%
-   testJAVAHOME
-
-
-:: test JAVA_HOME is set Correctly
-:testJAVAHOME
-if not exist "%JAVA_HOME%\bin\java.exe" goto wrongJAVAHOME
-if not exist "%JAVA_HOME%\bin\javac.exe" goto wrongJAVAHOME2
-goto gotJAVAHOME
-
-
-:wrongJAVAHOME
-echo JAVA_HOME: "%JAVA_HOME%"
-echo Couldn't find "%JAVA_HOME%\bin\java.exe"
-echo The JAVA_HOME environment variable is not defined correctly
-echo This environment variable is needed to run this program
-goto pauseANdExit  
-
-:wrongJAVAHOME2
-echo JAVA_HOME: "%JAVA_HOME%"
-echo Couldn't find "%JAVA_HOME%\bin\javac.exe"
-echo The JAVA_HOME environment variable is not defined correctly
-echo This environment variable is needed to run this program
-echo NB: JAVA_HOME should point to a JDK not a JRE
-goto pauseANdExit 
-
-::set the RUNJAVA and exit
-:gotJAVAHOME
- set RUNJAVA=%JAVA_HOME%\bin\java.exe
- set PATH=%JAVA_HOME%\bin;%PATH%
- echo JAVA_HOME: "%JAVA_HOME%"
- echo Your environment has successfully been set up to run Greenstone3
- goto exit
-
-::try find java on the search path
-:noJAVAHOME
-:: Check if Java is on the search path
- echo %PATH%| winutil\which.exe java.exe | winutil\setvar.exe JAVAPATH > setjava.bat
- call setjava.bat
- del setjava.bat
-
-if exist "%JAVAPATH%\bin\java.exe" goto gotJava
- :: Still haven't found anything, so try looking in the registry (gulp!)
-  type nul > jdk.reg
-  regedit /E jdk.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit"
-  type jdk.reg > jdk.txt
-  del jdk.reg
-  type nul > jre.reg
-  regedit /E jre.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment"
-  type jre.reg > jre.txt
-  del jre.reg
-
-  winutil\findjava.exe jdk.txt jre.txt | winutil\setvar.exe JAVAPATH > setjava.bat
-  del jdk.txt
-  del jre.txt
-  call setjava.bat
-  del setjava.bat
-
-  :: If nothing was found in the registry, we're stuck
-  if "%JAVAPATH%" == "" goto noJava
-    goto gotJava
-
-:gotJava
-  set JRE_HOME=%JAVAPATH%
-  goto testJREHOME 
-
-
-:noJava
-    echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
-    echo At least one of these environment variable is needed to run Greenstone3  
-    echo You must install a Java Run Environment (version 1.4 or greater) 
-    echo and set the JRE_HOME environment variable before running the
-    echo Greenstone 3 Digital Library Software.
-    pause
-    goto exit
-
-:pauseAndExit
- pause
- goto exit 
- 
-:exit
-
-
-
+echo GSDL3SRCHOME : %GSDL3SRCHOME%
+echo GSDL3HOME    : %GSDL3HOME%
+echo JVM          : %RUNJAVA%
