SMX4KNL-87: Backport windows batch fixes

git-svn-id: https://svn.apache.org/repos/asf/servicemix/smx4/kernel/branches/kernel-1.0.x@698723 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/assembly/src/main/distribution/windows-text/bin/servicemix.bat b/assembly/src/main/distribution/windows-text/bin/servicemix.bat
index 63011e0..c108269 100755
--- a/assembly/src/main/distribution/windows-text/bin/servicemix.bat
+++ b/assembly/src/main/distribution/windows-text/bin/servicemix.bat
@@ -110,15 +110,38 @@
 set CLASSPATH=%CLASSPATH%;%SERVICEMIX_HOME%\lib\servicemix.jar;%SERVICEMIX_HOME%\lib\servicemix-jaas-boot.jar
 
 rem Execute the JVM or the load the profiler
-if "%SERVICEMIX_PROFILER%" == "" goto :EXECUTE
+if "%SERVICEMIX_PROFILER%" == "" goto :RUN
     rem Execute the profiler if it has been configured
     call :warn Loading profiler script: %SERVICEMIX_PROFILER_SCRIPT%
     call %SERVICEMIX_PROFILER_SCRIPT%
 
+:RUN
+    SET OPTS=-Dservicemix.startLocalConsole=true -Dservicemix.startRemoteShell=true
+    SET SHIFT=false
+    if "%1" == "console" goto :EXECUTE_CONSOLE
+    if "%1" == "server" goto :EXECUTE_SERVER
+    if "%1" == "client" goto :EXECUTE_CLIENT
+    goto :EXECUTE
+
+:EXECUTE_CONSOLE
+    SET SHIFT=true
+    goto :EXECUTE    
+
+:EXECUTE_SERVER
+    SET OPTS="-Dservicemix.startLocalConsole=false -Dservicemix.startRemoteShell=true"
+    SET SHIFT=true
+    goto :EXECUTE
+
+:EXECUTE_CLIENT
+    SET OPTS="-Dservicemix.startLocalConsole=true -Dservicemix.startRemoteShell=false"
+    SET SHIFT=true
+    goto :EXECUTE
+
 :EXECUTE
-    SET OPTS=-Dservicemix.startLocalConsole=true -Dservicemix.startRemoteShell=true    
+    if "%SHIFT%" == "true" SET ARGS=%2 %3 %4 %5 %6 %7 %8
+    if not "%SHIFT%" == "true" SET ARGS=%1 %2 %3 %4 %5 %6 %7 %8    
     rem Execute the Java Virtual Machine
-    "%JAVA%" %JAVA_OPTS% %OPTS% -classpath "%CLASSPATH%" -Dservicemix.home="%SERVICEMIX_HOME%" -Dservicemix.base="%SERVICEMIX_BASE%" org.apache.servicemix.kernel.main.Main %*
+    "%JAVA%" %JAVA_OPTS% %OPTS% -classpath "%CLASSPATH%" -Dservicemix.home="%SERVICEMIX_HOME%" -Dservicemix.base="%SERVICEMIX_BASE%" org.apache.servicemix.kernel.main.Main %ARGS%
 
 rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 
diff --git a/gshell/gshell-core/src/main/resources/org/apache/geronimo/gshell/spring/bin/servicemix.bat b/gshell/gshell-core/src/main/resources/org/apache/geronimo/gshell/spring/bin/servicemix.bat
index b472a54..13c155a 100644
--- a/gshell/gshell-core/src/main/resources/org/apache/geronimo/gshell/spring/bin/servicemix.bat
+++ b/gshell/gshell-core/src/main/resources/org/apache/geronimo/gshell/spring/bin/servicemix.bat
@@ -22,4 +22,4 @@
 SETLOCAL
 SET SERVICEMIX_HOME=${servicemix.home}
 
-%SERVICEMIX_HOME%\bin\servicemix.bat "$*"
\ No newline at end of file
+%SERVICEMIX_HOME%\bin\servicemix.bat %*