Archive: Starting a Windows service


Starting a Windows service
I created a simple silent installation script to install a Windows service using the System plug-in created by dselkirk, found here:

http://nsis.sourceforge.net/archive/...php?pageid=345

My script is pasted below. The executable file is a java launcher (created with NSIS) that runs a java program that listens for connections on a specified port.

When I launch rcb_serv.exe (the output file of my service insallation script), the service is created but not yet started (as expected). When I start the service using the Windows service manager, the java program begins running as expected. However, the Windows service manager believes that the service did not start. It throws the error:

Error 1053: The service did not respond to the start or control request in a timely fashion

Am I supposed to do something else in the NSIS script to make the service manager happy? Or is my program supposed to do something to complete the handshake?

Here's my script:

; Service Installer
;--------------

Name "RCB_Service_Install"
Caption "RCB Service Installer"
OutFile "rcb_serv.exe"

SilentInstall silent
AutoCloseWindow true
ShowInstDetails nevershow

!include servicelib.nsh
!define EXE_FILE "rcb.exe"

Section ""

!insertmacro SERVICE "create" "rcb_server"\
"path=c:\Documents and Settings\<my user name>\My Documents\RCB\rcb.exe;\
autostart=1;display=rcb_server;"


SectionEnd


You can't start any executable as a service. A server executable must act as a service, call specific API functions and respond to specific messages.

See more at MSDN:

http://msdn2.microsoft.com/en-us/library/ms687416.aspx


Thanks, I figured that was the case. I did find this nifty open source tool for wrapping java server apps as Windows services and Unix daemons. It took me five minutes to create a Windows service with it.
.