Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Working on version Insatllsheild5.5


9 replies to this topic

ssd

ssd
  • Members
  • 6 posts

Posted 15 December 2004 - 12:01

Hi All,

can you plzzz.. let me know how to give parameters in LauchAppAndWait.

I tried various combination like

TARGETDIR = "C:/Program Files/Apache Software Foundation/jakarta-tomcat-5.0.28/bin";
with szPathTomcat = TARGETDIR ^ "/service.bat install service";

or
TARGETDIR = "C:\\Program Files\\Apache Software Foundation\\jakarta-tomcat-5.0.28\\bin"; with szPathTomcat = TARGETDIR ^ "\\service.bat install service";


if (LongPathToQuote (szPathTomcat, TRUE) < 0) then
WriteLogMsg("First call to LongPathToQuote failed.");
endif;
szPathTomcat = "/C" + szPathTomcat;
_LaunchAppEx("cmd.exe" ,szPathTomcat, WAIT,SW_HIDE,-1,nExit);

cmd.exe gave because I using windows NT 2000 and trying to install tomcat5 as NT service using .bat file

I will be very thankful if help me out as this first program of mine.
thanks in advance
ssd

Perotin

Perotin
  • Full Members
  • 407 posts

Posted 15 December 2004 - 13:47

1. if you connect path parts with ^ you don't have to care about backslashes, leave it to InstallScript.
2. be sure just to put the .bat path into quotes, you have put the parameters into it, so there may be some problem to find the specified executable ...
3. i cannot give infos about _LaunchAppEx (didn't try it yet), but the call with LaunchAppAndWait show be
CODE
TARGETDIR = PROGRAMFILES ^"Apache Software Foundation\\jakarta-tomcat-5.0.28\\bin";
szPathTomcat = TARGETDIR ^ "service.bat";
LongPathToQuote (szPathTomcat, TRUE);
szParam = " install service";
LaunchAppAndWait("cmd.exe", szPathTomcat + szParam, WAIT);


give this a try ...
Gruß / regards
Thomas

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 15 December 2004 - 16:02

You shouldn't include the command line parameters in the quotes.

Perotin

Perotin
  • Full Members
  • 407 posts

Posted 16 December 2004 - 10:03

For cmd.exe, the first param is the service.bat, if its path contains blanks there have to be quotes around, unless cmd.exe will get multiple params and won't find the executable ...

But for the batch file's param, i agree, they should not be quoted.

ssd, does it work for you?
Gruß / regards
Thomas

ssd

ssd
  • Members
  • 6 posts

Posted 16 December 2004 - 10:10

Hi Perotin & Stefan,

Thanks a lot for your response.
I tried with example and suggestion you have given.command prompt is opening but service is not getting installed.I checked my batch file which I can run manually on cmd.exe. I removed params "install service" from .bat, and tried nothing is happened.
Not getting where is the problem?

TARGETDIR = PROGRAMFILES ^"Apache Software Foundation\\jakarta-tomcat-5.0.28\\bin";
szPathTomcat = TARGETDIR ^ "service.bat";
LongPathToQuote (szPathTomcat, TRUE);
//szParam = " install service";
LaunchAppAndWait("cmd.exe", szPathTomcat, WAIT);

here is my .bat that have changed not to take parameters

@echo off
if "%OS%" == "Windows_NT" setlocal
rem ---------------------------------------------------------------------------
rem NT Service Install/Uninstall script
rem
rem Options
rem install Install the service using Tomcat5 as service name.
rem Service is installed using default settings.
rem remove Remove the service from the System.
rem
rem name (optional) If the second argument is present it is considered
rem to be new service name
rem
rem $Id: service.bat,v 1.5.2.1 2004/08/23 22:54:32 mturk Exp $
rem ---------------------------------------------------------------------------
set JAVA_HOME=C:/Program Files/Cisco Systems/CiscoER/jre1.4
rem Guess CATALINA_HOME if not defined
set CURRENT_DIR=%cd%
if not "%CATALINA_HOME%" == "" goto gotHome
set CATALINA_HOME=%cd%
if exist "%CATALINA_HOME%\bin\tomcat5.exe" goto okHome
rem CD to the upper dir
cd ..
set CATALINA_HOME=%cd%
:gotHome
if exist "%CATALINA_HOME%\bin\tomcat5.exe" goto okHome
echo The tomcat.exe was not found...
echo The CATALINA_HOME environment variable is not defined correctly.
echo This environment variable is needed to run this program
goto end
rem Make sure prerequisite environment variables are set
if not "%JAVA_HOME%" == "" goto okHome
echo The JAVA_HOME environment variable is not defined
echo This environment variable is needed to run this program
goto end
:okHome
if not "%CATALINA_BASE%" == "" goto gotBase
set CATALINA_BASE=%CATALINA_HOME%
:gotBase

set EXECUTABLE=%CATALINA_HOME%\bin\tomcat5.exe

rem Set default Service name
set SERVICE_NAME=Tomcat5
set PR_DISPLAYNAME=Apache Tomcat


goto setServiceName
set SERVICE_NAME=%2
set PR_DISPLAYNAME=Apache Tomcat %2
:setServiceName

goto doInstall

:doInstall
rem Install the service
echo Installing the service '%SERVICE_NAME%' ...
echo Using CATALINA_HOME: %CATALINA_HOME%
echo Using JAVA_HOME: %JAVA_HOME%

rem Use the environment variables as an exaple
rem Each command line option is prefixed with PR_

set PR_DESCRIPTION=Apache Tomcat Server - http://jakarta.apache.org/tomcat
set PR_INSTALL=%EXECUTABLE%
set PR_LOGPATH=%CATALINA_HOME%\logs
set PR_CLASSPATH=%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\bin\bootstrap.jar
rem Set the server jvm frrom JAVA_HOME
set PR_JVM=%JAVA_HOME%\bin\server\jvm.dll
rem You can use the 'set PR_JVM=auto' for default JVM
"%EXECUTABLE%" //IS//%SERVICE_NAME% --StartClass org.apache.catalina.startup.Bootstrap --StopClass org.apache.catalina.startup.Bootstrap --StartParams start --StopParams stop
rem Clear the environment variables. They are not needed any more.
set PR_DISPLAYNAME=
set PR_DESCRIPTION=
set PR_INSTALL=
set PR_LOGPATH=
set PR_CLASSPATH=
set PR_JVM=
rem Set extra parameters
"%EXECUTABLE%" //US//%SERVICE_NAME% --JvmOptions "-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%\common\endorsed" --StartMode jvm --StopMode jvm
rem More extra parameters
set PR_STDOUTPUT=%CATALINA_HOME%\logs\stdout.log
set PR_STDERROR=%CATALINA_HOME%\logs\stderr.log
"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp" --JvmMs 128 --JvmMx 256
echo The service '%SERVICE_NAME%' has been installed.

:end
cd %CURRENT_DIR%

Thank you once again for your prompt and speedy reply
ssd



Perotin

Perotin
  • Full Members
  • 407 posts

Posted 16 December 2004 - 10:38

Hi ssd!

If there is no sign that the batch file runs, try to run a simple batch file that just opens a dos box or something ...
Just to make clear that all paths are set correctly.

The batch file runs when started manually, so this is not the problem.
Maybe debug up to the line, where you want to start the service.bat and look into the parameters of LaunchAppAndWait and check them, maybe copy them into the command line to test for error messages within the command line ....
Gruß / regards
Thomas

ssd

ssd
  • Members
  • 6 posts

Posted 20 December 2004 - 07:23

Hi Perotin,

Thanks for your reply. Batch file runs in dos window without any problem.

I debugged with log messages the path I am giving is correct.when I pick up the path from logger messages and using on cmd.exe with cd program files\...... its runs.

but it is not able to run using install function LaunchAppAndWait/LaunchAppEx. Function just opening cmd.exe but not running the batch file.
I saw many responses on forum for the batch file and most of got success with the same procedure.

I will try some other method than install function now...

TARGETDIR = PROGRAMFILES ^"Apache Software Foundation\\jakarta-tomcat-5.0.28\\bin";
WriteLogMsg("Path = " + TARGETDIR) ;
szPathTomcat = TARGETDIR ^ "service.bat";
WriteLogMsg("FullPath = " + szPathTomcat) ;
LongPathToQuote (szPathTomcat, TRUE);
szParam = " install";
LaunchAppAndWait("cmd.exe", szPathTomcat+szParam, WAIT);
WriteLogMsg("FullPath = " + szPathTomcat+szParam) ;

Thank you for your reply
Swati

Perotin

Perotin
  • Full Members
  • 407 posts

Posted 20 December 2004 - 10:01

It may be a weird way of debugging, but you can vary the batch file to display the actions (remove "@echo off") and add some "pause" after some lines of the file.
So you can see what the bacth file does.
Maybe it's a path problem, so you have the right path when running it from the commandlline, but not when starting from installscript
I see a "cd .." in the batchfile, but no definition, where it is run.
Maybe you use something like
CODE
c:
cd %ProgramFiles%
cd "Apache Software Foundation\jakarta-tomcat-5.0.28\bin"
to set a starting directory for the bacthfile ...
Gruß / regards
Thomas

ssd

ssd
  • Members
  • 6 posts

Posted 21 December 2004 - 06:20

Hi Perotin,

Install script opens cmd.exe which is completely blank with "C:>" prompt, I can not see echos or execution of batch file when I run install script, so I am not able to do runtime debug.

Yes, you are absolutly right, for testing of service batch file I do cd up to the bin folder and run batch file.

Now I have changed batch file with your suggestions and tried to run through install script but it was unsuccessful sad.gif

service.bat

rem @echo off
if "%OS%" == "Windows_NT" setlocal
rem ---------------------------------------------------------------------------
rem NT Service Install/Uninstall script
rem
rem Options
rem install Install the service using Tomcat5 as service name.
rem Service is installed using default settings.
rem remove Remove the service from the System.
rem
rem name (optional) If the second argument is present it is considered
rem to be new service name
rem
rem $Id: service.bat,v 1.5.2.1 2004/08/23 22:54:32 mturk Exp $
rem ---------------------------------------------------------------------------
set JAVA_HOME=C:\Program Files\Cisco Systems\CiscoER\jre1.4
rem Guess CATALINA_HOME if not defined

if not "%CATALINA_HOME%" == "" goto gotHome

set CATALINA_HOME=C:\Program Files\Apache Software Foundation\jakarta-tomcat-5.0.28
if exist "%CATALINA_HOME%\bin\tomcat5.exe" goto okHome

:gotHome

if exist "%CATALINA_HOME%\bin\tomcat5.exe" goto okHome
echo The tomcat.exe was not found...
echo The CATALINA_HOME environment variable is not defined correctly.
echo This environment variable is needed to run this program
goto end

rem Make sure prerequisite environment variables are set
if not "%JAVA_HOME%" == "" goto okHome
echo The JAVA_HOME environment variable is not defined
echo This environment variable is needed to run this program
goto end

:okHome
if not "%CATALINA_BASE%" == "" goto gotBase
set CATALINA_BASE=%CATALINA_HOME%
:gotBase

set EXECUTABLE=%CATALINA_HOME%\bin\tomcat5.exe

rem Set default Service name
set SERVICE_NAME=Tomcat5
set PR_DISPLAYNAME=Apache Tomcat

if "%1" == "" goto displayUsage
if "%2" == "" goto setServiceName
set SERVICE_NAME=%2
set PR_DISPLAYNAME=Apache Tomcat %2
:setServiceName
if %1 == install goto doInstall
if %1 == remove goto doRemove
echo Unknown parameter "%1"
:displayUsage
echo
echo Usage: service.bat install/remove [service_name]
goto end

:doRemove
rem Remove the service
"%EXECUTABLE%" //DS//%SERVICE_NAME%
echo The service '%SERVICE_NAME%' has been removed
goto end

:doInstall
rem Install the service
echo Installing the service '%SERVICE_NAME%' ...
echo Using CATALINA_HOME: %CATALINA_HOME%
echo Using JAVA_HOME: %JAVA_HOME%

rem Use the environment variables as an exaple
rem Each command line option is prefixed with PR_

set PR_DESCRIPTION=Apache Tomcat Server - http://jakarta.apache.org/tomcat
set PR_INSTALL=%EXECUTABLE%
set PR_LOGPATH=%CATALINA_HOME%\logs
set PR_CLASSPATH=%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\bin\bootstrap.jar
rem Set the server jvm frrom JAVA_HOME
set PR_JVM=%JAVA_HOME%\bin\server\jvm.dll
rem You can use the 'set PR_JVM=auto' for default JVM
"%EXECUTABLE%" //IS//%SERVICE_NAME% --StartClass org.apache.catalina.startup.Bootstrap --StopClass org.apache.catalina.startup.Bootstrap --StartParams start --StopParams stop
rem Clear the environment variables. They are not needed any more.
set PR_DISPLAYNAME=
set PR_DESCRIPTION=
set PR_INSTALL=
set PR_LOGPATH=
set PR_CLASSPATH=
set PR_JVM=
rem Set extra parameters
"%EXECUTABLE%" //US//%SERVICE_NAME% --JvmOptions "-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%\common\endorsed" --StartMode jvm --StopMode jvm
rem More extra parameters
set PR_STDOUTPUT=%CATALINA_HOME%\logs\stdout.log
set PR_STDERROR=%CATALINA_HOME%\logs\stderr.log
"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp" --JvmMs 128 --JvmMx 256
echo The service '%SERVICE_NAME%' has been installed.

:end
cd %CURRENT_DIR%

Thanks & Regards,
Swati


ssd

ssd
  • Members
  • 6 posts

Posted 21 December 2004 - 14:04

Hi Perotin,

If I keep my service.bat on C drive then it runs fine with install script. I guess the path name PROGRAMFILES ^"Apache Software Foundation\\jakarta-tomcat-5.0.28\\bin" not getting to cmd.exe but when I put it on C drive cmd.exe getting it.

I used LongPathToShortPath(szPath) but still not got it worked.

So now I will keep my serive.bat on C drive to install service.

Thanks for your timely feedback and support.

Regards,
Swati