Question

I created an installer with install4j that calls the provided Tomcat service.bat file to create a Windows service.

That works fine, but is there anyway to modify the service.bat so by default the installed service is Automatic (Delayed Start) as opposed to Automatic or Manual?

According to this page: http://tomcat.apache.org/tomcat-7.0-doc/windows-service-howto.html

The --Startup parameter takes either auto or manual with a default of manual if left empty. I'm a little confused because I left it out and my services are set to Automatic after installation, which contradicts that page.

Was it helpful?

Solution

Doesn't seem like a parameter for Automatic (Delayed Start) is supported so I ended up simply calling a .bat file after the service is installed. It sets the appropriate key/value in the Windows registry to mark a service as delayed-start.

reg add "HKLM\SYSTEM\CurrentControlSet\services\%1" /v DelayedAutostart /t REG_DWORD /d 0x1 /f"

Just run the batch file, passing an argument for the service name.

automaticDelayedStart.bat MyService

OTHER TIPS

You can also write a batch script as below:

rem :To create service with name TestTomcat
call service.bat install TestTomcat

rem :To set tomcat service as a startup service and also set heap size.
call tomcat7 //US//TestTomcat --Startup=auto ++JvmOptions=-Xmx2048m

rem :To start service
call sc start TestTomcat

And from installer you can run this batch file using "Run executable or file" action.

Thanks

-Satish Lakhani

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top